Description Usage Arguments Examples
Dynamically change the data of a shiny plot.
1 | change_data(g, data)
|
g |
An object of class |
data |
New dataset to replaced the one used to currently plot the data. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | 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)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.