Shiny App

Das könnte Ihnen auch gefallen

Als pdf oder txt herunterladen
Als pdf oder txt herunterladen
Sie sind auf Seite 1von 10

Shiny Apps

Scripting für Data Scientists


Christian Jölly
(WS20/21, 18.11.2020)
2

Was ist Shiny?

Shiny ist ein R-Paket mit dem einfach und schnell interaktive
Webanwendungen mit R erstellt werden können.
3

Wofür kann man Shiny einsetzen?

• Interaktive Berichte
• Interaktive Dashboards

• für alles was in einen Browser passt …


Jedoch wird es wohl einen Bedarf für R beim Einsatz von Shiny geben ☺
4

Wie funktioniert Shiny?

Architektur ähnlich dem Model-View-Controller (MVC) Design Pattern

Model: Daten
View: User Interface
Controller: Businesslogik

Quelle: https://en.wikipedia.org/wiki/Model-view-controller
5

Minimal working example (MWE)


• Laden des Shiny R Packages
• Setzen des User Interfaces
• Implementierung der Businesslogik
• Ausführen der App
6

Elemente in Shiny
• Seite basicPage, fluidPage
• Layout fluidRow, flowLayout, sidebarLayout, splitLayout,
sidebarPanel, tabsetPanel, ...
• Elemente tags$a, tags$input, tags$div, tags$table, ...
• „Reactive“ textInput, selectInput, actionButton,...
textOutput, dataTableOutput, plotOutput, ...

Referenz: https://shiny.rstudio.com/reference/shiny/1.5.0/
7

Reactive Elements
Jedes "Reactive" Element löst eine Reaktion in der App aus,
worauf die App mit einer Aktion antwortet.

→ Benutzereingabe (*)
→ reactive Element informiert App
→ App führt Businesslogik aus
→ Businesslogik aktualisiert Model
→ User Interface aktualisiert View

(*) jedes Zeichen! Quelle: https://shiny.rstudio.com/images/shiny-cheatsheet.pdf


8

Events
erlauben gezielte Reaktion auf Ereignisse von Elementen
(zu viele reaktive Elemente verlangsamen App!)

• Benutzeraktion, z.B. Buttonklick


• Button löst Event aus
• „Event-Listener “ wird ausgeführt
• App führt Businesslogik aus
• Businesslogik aktualisiert Model
• User Interface aktualisiert View

Quelle: https://shiny.rstudio.com/images/shiny-cheatsheet.pdf
9

Deployment Szenarien
Wie und wo können Shiny Apps betrieben werden?

• RStudio: nur lokal auf der eigenen Maschine, no remote!

• Cloud: Shinyapps.io (gratis vs. bezahlt)

• Server: Shiny Server (Open Source)


RStudio Connect (Kommerziell)

Quelle: https://shiny.rstudio.com/deploy/
10

weitere Informationen
• https://shiny.rstudio.com/tutorial/
• https://shiny.rstudio.com/gallery/
• https://shiny.rstudio.com/reference/shiny/

• https://mastering-shiny.org/index.html

• https://shiny.rstudio.com/images/shiny-cheatsheet.pdf

Das könnte Ihnen auch gefallen