Karl Ho
School of Economic, Political and Policy Sciences
University of Texas at Dallas
# install.packages("shiny")
# install.packages("shinythemes")
library(shiny)
library(shinythemes)
# Create User Interface
ui <− fluidPage ()
# Build R objects displayed in UI
server <− function(input , output){}
# Create Shiny app
shinyApp(ui = ui, server = server)
ui: Nested R functions that assemble an HTML user interface for the app (some HTML knowledge needed)
server: A function with instructions on how to build and rebuild the R objects displayed in the UI
shinyApp: Combines ui and server into a functioning app
library(shiny)
ui = fluidPage(
numericInput(inputId = "n", "Sample size", value = 50),
plotOutput(outputId = "hist")) server = function(input , output){ output$hist = renderPlot ({
hist(rnorm(input$n)) })}shinyApp(ui = ui , server = server)Reactive values work together with reactive functions. Call a reactive value from within the arguments of one of these functions to avoid the error
Operation not allowed without an active reactive context.
fileInput(inputId, label, multiple, accept)
numericInput(inputId, label, value, min, max, step)
passwordInput(inputId, label, value)
radioButtons(inputId, label, choices, selected, inline)
selectInput(inputId, label, choices, selected, multiple, selectize, width, size) (also selectizeInput())
sliderInput(inputId, label, min, max, value, step, round, format, locale, ticks, animate, width, sep, pre, post)