Dynamically change the data of a shiny plot.
change_data(g, data)
g | An object of class |
---|---|
data | New dataset to replaced the one used to currently plot the data. |
library(shiny) makeData <- function(){ data.frame( x = runif(100), y = runif(100), size = runif(100) ) } ui <- fluidPage( g2Output("plot"), actionButton("change", "Change data") ) server <- function(input, output){ output$plot <- renderG2({ g2(makeData(), asp(x, y, size = size)) %>% fig_point() }) observeEvent(input$change, { g2_proxy("plot") %>% change_data(makeData()) }) } if(interactive()){ shinyApp(ui, server) }