This R Markdown document is made interactive using Shiny. Unlike the more traditional workflow of creating static reports, you can now create documents that allow your readers to change the assumptions underlying your analysis and see the results immediately.
To learn more, see Interactive Documents.
You can embed Shiny inputs and outputs in your document. Outputs are automatically updated whenever inputs change. This demonstrates how a standard R plot can be made interactive by wrapping it in the Shiny renderPlot
function. The selectInput
and sliderInput
functions create the input widgets used to drive the plot.
shinyApp( ui = fluidPage( selectInput("region", "Region:", choices = colnames(WorldPhones)), submitButton("Submit"), plotOutput("phonePlot") ), server = function(input, output) { output$phonePlot <- renderPlot({ barplot(WorldPhones[,input$region]*1000, ylab = "Number of Telephones", xlab = "Year") writeChar(input$region, "out.txt", nchar = nchar(input$region), eos=NULL) }) }, options = list(height = 500) )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.