Shiny: Make Your R Code
Interactive
Craig Wang
MScin StatisticsatETH
R Programmerat Institutfür MathematikUZH
Zurich R Use...
Brief Demo
http://t.uzh.ch/se
2
Zurich R User Group Meetups
December
Overview
• Introduction
• Setup and structure
• Work-through example
• Deploy and Share
• More Resources
3
Zurich R User G...
Introduction to Shiny
• A freely-available third party R package created by Rstudio
• Allows to transform R code into inte...
Setup and Structure
• Simply install and load the package ‘shiny’
• Select a path to save all your files about your Shiny ...
Work-through Example
library(shiny)
shinyUI(fluidPage(
titlePanel("Hello Shiny!"), # define title
sidebarLayout( # choose ...
Work-through Example
x <- faithful[, 2] # Old Faithful Geyser data
bins <- seq(min(x), max(x), length.out = n + 1) # n is ...
Work-through Example
x <- faithful[, 2] # Old Faithful Geyser data
bins <- seq(min(x), max(x), length.out = n + 1) # n is ...
Work-through Example
x <- faithful[, 2] # Old Faithful Geyser data
bins <- seq(min(x), max(x), length.out = n + 1) # n is ...
Work-through Example
• runApp(“Hello Shiny”)
10
Zurich R User Group Meetups
December
Deploy and Share
• Once the application is ready, it is free to share with the public
• Cost: free for 25 hours/month, up ...
More Resources
• Cheat sheets
• Tutorial
• Shiny gallery
12
Zurich R User Group Meetups
December
Final Notes
• Demo website: http://t.uzh.ch/se
• My contact: craigwang247@gmail.com
• Thanks Christoph and Heidi for organ...
Nächste SlideShare
Wird geladen in …5
×

December 2015 Meetup - Shiny: Make Your R Code Interactive - Craig Wang

321 Aufrufe

Veröffentlicht am

Do you want to create R functions that can be accessed by non-R users? Do you want your R code to be interactive and alive? Shiny is a freely-available R package that provides a programming environment to turn your R analyses into interactive web applications. In this presentation, I will introduce the Shiny package and its basic structure. It enables our R code to dynamically react to user input, and it is straight-forward to implement without any prior knowledge in website design. I will also demonstrate some examples of web applications designed using Shiny.

Veröffentlicht in: Daten & Analysen
0 Kommentare
0 Gefällt mir
Statistik
Notizen
  • Als Erste(r) kommentieren

  • Gehören Sie zu den Ersten, denen das gefällt!

Keine Downloads
Aufrufe
Aufrufe insgesamt
321
Auf SlideShare
0
Aus Einbettungen
0
Anzahl an Einbettungen
2
Aktionen
Geteilt
0
Downloads
6
Kommentare
0
Gefällt mir
0
Einbettungen 0
Keine Einbettungen

Keine Notizen für die Folie

December 2015 Meetup - Shiny: Make Your R Code Interactive - Craig Wang

  1. 1. Shiny: Make Your R Code Interactive Craig Wang MScin StatisticsatETH R Programmerat Institutfür MathematikUZH Zurich R User Group Meetups December 1
  2. 2. Brief Demo http://t.uzh.ch/se 2 Zurich R User Group Meetups December
  3. 3. Overview • Introduction • Setup and structure • Work-through example • Deploy and Share • More Resources 3 Zurich R User Group Meetups December
  4. 4. Introduction to Shiny • A freely-available third party R package created by Rstudio • Allows to transform R code into interactive web applications • Provide native programming environments • Easy to get hands on, no website design experience required 4 Zurich R User Group Meetups December
  5. 5. Setup and Structure • Simply install and load the package ‘shiny’ • Select a path to save all your files about your Shiny application • Basic files • ui.R is a script file that implements all the user interface elements such as buttons,drop-downmenus, sliders • server.R is a scriptfile that takes input from the interfaceand processit, finally update the interface • runApp(“Hello Shiny”) in R 5 Zurich R User Group Meetups December
  6. 6. Work-through Example library(shiny) shinyUI(fluidPage( titlePanel("Hello Shiny!"), # define title sidebarLayout( # choose layout sidebarPanel( sliderInput("bins", "Number of bins:", min = 1, max = 50, value = 30) ), mainPanel( plotOutput("distPlot") )) )) 6 Zurich R User Group Meetups December
  7. 7. Work-through Example x <- faithful[, 2] # Old Faithful Geyser data bins <- seq(min(x), max(x), length.out = n + 1) # n is number of bins hist(x, breaks = bins, col = 'darkgray', border = 'white') 7 Zurich R User Group Meetups December
  8. 8. Work-through Example x <- faithful[, 2] # Old Faithful Geyser data bins <- seq(min(x), max(x), length.out = n + 1) # n is number of bins hist(x, breaks = bins, col = 'darkgray', border = 'white') x <- faithful[, 2] # Old Faithful Geyser data bins <- seq(min(x), max(x), length.out = input$bins + 1) hist(x, breaks = bins, col = 'darkgray', border = 'white') 8 Zurich R User Group Meetups December
  9. 9. Work-through Example x <- faithful[, 2] # Old Faithful Geyser data bins <- seq(min(x), max(x), length.out = n + 1) # n is number of bins hist(x, breaks = bins, col = 'darkgray', border = 'white') library(shiny) shinyServer(function(input, output) { output$distPlot <- renderPlot({ x <- faithful[, 2] # Old Faithful Geyser data bins <- seq(min(x), max(x), length.out = input$bins + 1) hist(x, breaks = bins, col = 'darkgray', border = 'white') }) }) 9 Zurich R User Group Meetups December
  10. 10. Work-through Example • runApp(“Hello Shiny”) 10 Zurich R User Group Meetups December
  11. 11. Deploy and Share • Once the application is ready, it is free to share with the public • Cost: free for 25 hours/month, up to 10,000 hours/month • Wide range of applications on Shinyapp.io • https://jnuke2000.shinyapps.io/ShinyDash • https://leehbi.shinyapps.io/Sales-Pricing-Tool/ • https://healthrank.shinyapps.io/demo/ 11 Zurich R User Group Meetups December
  12. 12. More Resources • Cheat sheets • Tutorial • Shiny gallery 12 Zurich R User Group Meetups December
  13. 13. Final Notes • Demo website: http://t.uzh.ch/se • My contact: craigwang247@gmail.com • Thanks Christoph and Heidi for organizing this, also Sanitas for sponsoring the venue. 13 Zurich R User Group Meetups December

×