Load the shiny and testjs libraries.
library(shiny) library(testjs)
Simulate some data.
x <- rnorm(100) grp <- sample(1:3, 100, replace=TRUE) y <- x*grp + rnorm(100)
Define the ui
and server
bits for the Shiny app. It's going to just have a check box for turning the coloring of points by group.
ui <- shinyUI(fluidPage( checkboxInput("color_points", "Color points by group", value=TRUE), iplot_output('iplot') )) server <- function(input, output) { output$iplot <- iplot_render( if(input$color_points) { iplot(x, y, grp) } else { iplot(x, y) } ) }
Finally, the Shiny app.
shinyApp(ui=ui, server=server, options=list(height=900))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.