The samples displayed on http://shiny.math.uzh.ch page are the following
R Sample: Hello
The folder hello includes two files.
- server.R
library(shiny) # Define server logic required to draw a histogram shinyServer(function(input, output) { # Expression that generates a histogram. The expression is # wrapped in a call to renderPlot to indicate that: # # 1) It is "reactive" and therefore should be automatically # re-executed when inputs change # 2) Its output type is a plot output$distPlot <- renderPlot({ x <- faithful[, 2] # Old Faithful Geyser data bins <- seq(min(x), max(x), length.out = input$bins + 1) # draw the histogram with the specified number of bins hist(x, breaks = bins, col = 'darkgray', border = 'white') }) })
- ui.R
library(shiny) # Define UI for application that plots random distributions shinyUI(pageWithSidebar( # Application title headerPanel("It's Alive!"), # Sidebar with a slider input for number of observations sidebarPanel( sliderInput("bins", "Number of bins:", min = 1, max = 50, value = 30) ), # Show a plot of the generated distribution mainPanel( plotOutput("distPlot", height=250) ) ))
R Markdown Sample: rmd
The rmd Folder includes only one file:
- index.Rmd
--- title: "Shiny Doc" output: html_document runtime: shiny --- ```{r, echo=FALSE} shinyApp( ui = fluidPage( selectInput("region", "Region:", choices = colnames(WorldPhones)), plotOutput("phonePlot", height=270) ), server = function(input, output) { output$phonePlot <- renderPlot({ barplot(WorldPhones[,input$region]*1000, ylab = "Number of Telephones", xlab = "Year") }) }, options = list(height = 345) ) ```