9. Εγκατάσταση Shiny Package
Αρχικά θα πρέπει να γίνει εγκατάσταση του πακέτου:
install.packages(“shiny”)
Στη συνέχεια θα πρέπει να πληκτρολογήσουμε:
library(shiny)
Που πληκτρολογούμε τα παραπάνω;
10. Τι είναι το Shiny Package;
Το Shiny είναι πακέτο που επιτρέπει την Ανάπτυξη Εφαρμογών Διαδικτύου
αξιοποιώντας τη γλώσσα προγραμματισμού R. Η τελική εφαρμογή αποτελείται από
δύο τμήματα:
• frontend, το οποίο σχεδιάζει το user interface (UI),
• backend, το οποίο ενσωματώνει τη λογική της εφαρμογής από τη μεριά του server.
Frontend
User Interface
backend
Server Code
Δομή Εφαρμογής
11. Δομή Εφαρμογής Shiny App
User Interface (ui.R)
σειρά εμφωλευμένων (nested)
συναρτήσεων που καθορίζουν
την εμφάνιση και διάταξη
(layout) του περιεχομένου
server.R
εντολές που χρειάζεται ο
υπολογιστής για εκτέλεσης
της εφαρμογής
12. Διατάξεις (Layouts)
Το πακέτο Shiny χρησιμοποιεί την συνάρτηση fluidPage για να δημιουργήσει ένα
γραφικό περιβάλλον που προσαρμόζεται αυτόματα στο παράθυρο του web browser
του χρήστη.
Μπορούμε να τροποποιήσουμε το γραφικό περιβάλλον με την πρόσθεση γραφικών
στοιχείων στη συνάρτηση fluidPage.
Παράδειγμα
13. Βασικά widgets
Στοιχεία Ιστοσελίδας που συνδέονται με συναρτήσεις
του πακέτου shiny και προσδίδουν διαδραστικότητα
στην χρήση της
function widget
actionButton Action Button
checkboxGroupInput A group of check boxes
checkboxInput A single check box
dateInput
A calendar to aid date
selection
dateRangeInput
A pair of calendars for
selecting a date range
fileInput
A file upload control
wizard
helpText
Help text that can be
added to an input form
numericInput A field to enter numbers
radioButtons A set of radio buttons
selectInput
A box with choices to
select from
sliderInput A slider bar
submitButton A submit button
textInput A field to enter text
14. Πρόσθεση Widgets
Για να προσθέσουμε ένα widget στην εφαρμογή μας, τοποθετούμε μια συνάρτηση widget στο
sidebarPanel ή το mainPanel του αντικειμένου ui object.
Κάθε συνάρτηση widget απαιτεί ορίσματα (παραμέτρους) για να τρέξει. Τα πρώτα δυο είναι:
• το όνομα του widget (ορατό μόνο από την εφαρμογή)
• την ετικέτα (ορατό μόνο από τον χρήστη)
Τα υπόλοιπα ορίσματα διαφέρουν από widget σε widget και εξαρτώνται από την λειτουργία
τους
21. URL Links για την Δημιουργία Shiny Applications
• https://shiny.rstudio.com/tutorial/
• https://rstudio.github.io/shiny/tutorial/
• https://mastering-shiny.org/basic-app.html
• http://enhancedatascience.com/
• https://deanattali.com/blog/building-shiny-apps-tutorial/
• https://analyticsprofile.com/r-shiny-dashboard-tutorial/tutorial-1-
introduction-to-shiny-and-building-the-ui/
22. Videos για την Δημιουργία Shiny Applications
• https://www.youtube.com/watch?v=Gyrfsrd4zK0
• https://www.youtube.com/watch?v=oegRVT262Ig
• https://www.youtube.com/watch?v=78LmNiUNBy4
• https://www.youtube.com/watch?v=_0ORRJqctHE
• https://www.youtube.com/watch?v=SY7x2Ayj_b0
• https://www.youtube.com/watch?v=HVa42mJYppE
23. Webinars για την Δημιουργία Shiny Applications
• https://rstudio.com/resources/webinars/introduction-to-shiny/
24. Παρουσιάσεις για την Δημιουργία Shiny Applications
• https://www.slideshare.net/RohitDubey24/crash-course-on-r-shiny-
package
• https://www.slideshare.net/Sheffield_R_/introduction-to-shiny-for-r
• https://www.slideshare.net/heba_ahmad/iny-shiny
• https://www.slideshare.net/WendyChen56/a-tour-of-building-web-
applications-with-r-shiny
Editor's Notes
Στη συνέχεια θα δούμε κάποιες εφαρμογές σε γλώσσα R με Γραφικό Περιβάλλον Χρήσης. Θα ξεκινήσουμε από τις πιο απλές και στη συνέχεια θα δούμε και μια πιο πολύπλοκη.
Εγκαθιστούμε το Shiny Package στο R Studio. Δυστυχώς δεν βρήκα πληροφορίες αν μπορούμε να το εγκαταστήσουμε και στο Colab
Επιπλέον:
Ακολουθεί το reactive programming paradigm. Put simply, this is a type of programming which uses reactive expressions that keep track of the values on which they are based that can change (known as reactive values) and update themselves
whenever any of their reactive values change. So, in this example, the function that generates the random data and draws the graph is a reactive expression, and the number of random draws which it makes is a reactive value on which the expression depends. Thus whenever the number of draws changes, the function re-executes
Δεν απαιτεί γνώση No HTML/CSS/Javascript knowledge required to implement ... αλλά όποιος ξέρει μπορεί να την αξιοποιήσει για να φτιάξει εφαρμογές but fully customizable and extensible with HTML/CSS/JavaScript
Users can manipulate the UI, which will cause the server to update the UIs displays
Το πακέτο Shiny χρησιμοποιεί την συνάρτηση fluidPage για να δημιουργήσει ένα γραφικό περιβάλλον που προσαρμόζεται αυτόματα στο παράθυρο του web browser του χρήστη. Μπορούμε να τροποποιήσουμε το γραφικό περιβάλλον με την πρόσθεση γραφικών στοιχείων στη συνάρτηση fluidPage.
For example, the ui function below creates a user interface that has a title panel and a sidebar layout, which includes a sidebar panel and a main panel. Note that these elements are placed within the fluidPage function.
A web element that your users can interact with. Widgets provide a way for your users to send messages to the Shiny app.
Shiny widgets collect a value from your user. When a user changes the widget, the value will change as well.
Για να προσθέσουμε ένα widget στην εφαρμογή μας, τοποθετούμε μια συνάρτηση widget στο sidebarPanel ή το mainPanel του αντικειμένου ui object.
Κάθε συνάρτηση widget απαιτεί ορίσματα (παραμέτρους) για να τρέξει. Τα πρώτα δυο είναι:
το όνομα του widget: το οποίο δεν είναι ορατό από τον χρήστη της εφαρμογής αλλά απαιτείται για να έχουμε πρόσβαση στην τιμή του widget.
την ετικέτα: Η ετικέτα είναι το όνομα του widget που βλέπει ο χρήστης στην εφαρμογή. It should be a character string, but it can be an empty string "".
The remaining arguments vary from widget to widget, depending on what the widget needs to do its job.
shinyapps.io is a self-service platform that makes it easy for you to share your shiny applications on the web in just a few minutes.
RStudio Connect allows users to share and collaborate on the results they produce with R such as R Markdown documents, Shiny applications, Plumber APIs, and plots.
RStudio Connect connects you and the work you do in R with others as never before. Only RStudio Connect provides:
“One button” deployment for any Shiny application, R Markdown document, or any static plot or graph to a single environment.
The ability to manage and limit access to the work you’ve shared with others - and easily see the work they’ve shared with you.
“Hands free” scheduling of updates to your documents and automatic email distribution.