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))


kbroman/testjs documentation built on May 20, 2019, 8:14 a.m.