Albert Y. Kim
Monday 2015/03/30
Today we will create interactive web applications via Shiny. Shiny allows you to do so without knowing HTML, JavaScript, CSS, etc…
We won't be harnessing the full power of Shiny (i.e. using server.R and ui.R files),
but rather a simplified version using R Markdown.
For a tutorial on using Shiny fully see http://shiny.rstudio.com/tutorial/.
Rich Majerus is Vice President of Research of Third Coast Analytics: a consulting company which provides statistics, analysis, and data management services for higher education.
Go to the webpage and click on the map on the bottom left of the page. This was made via Shiny.
There are two chief components building a Shiny app:
inputPanel: Where your app takes inputs and stores them in an object called input. Ex: text, numerical values, sliders, radio buttons, etc.renderSOMETHING: After processing the inputs and data, Shiny renders an output: plots, table, text, etc.shiny packageThe inputPanel( ... ) section takes in two inputs (separated by a comma):
selectInput() which assigns a value to n_breaks based on a selection menu, formats the input box, and selects 20 as the default option.sliderInput() which assigns a value to bw_adjust based on a slider, formats the input box, and sets 1 as the default value.Note:
inputPanel() options are listed in “Widgets” on the cheatsheet.?selectInput, for example, to get a sense for the arguments.The renderPlot({ ... }) plots a histogram of the eruptions from the Old Faithful Geyser data set faithful.
Note:
n_breaks and bw_adjust, are stored within the input. For example, to interactively use n_breaks, we need to specify input$n_breaks.renderPlot({})Add a menu input option that allows you to specify the color of the smoother line.
Add a radio button so that the user has the option can limit consideration to only one sex.
Another tutorial: http://rmarkdown.rstudio.com/authoring_shiny.html