ggvis
ggvis copied to clipboard
shiny-binded ggvis seem to have a short lifetime?
I'm trying to generate and bind_shiny()
several ggvis plots to display them sporadically as a function of some user input. Here is an example:
ui <- fluidPage(
selectInput(
inputId = "col",
label = "column:",
choices = names(mtcars),
selected = "cyl"
),
htmlOutput("ggvis_plot")
)
server <- function(input, output) {
purrr::each2(mtcars, seq_along(mtcars), function(col, i) {
ggvis(data.frame(col), ~col) %>% bind_shiny(paste0("plot", i))
})
output$ggvis_plot <- renderUI({
i <- match(input$col, names(mtcars))
ggvisOutput(paste0("plot", i))
})
}
runApp(list(ui = ui, server = server))
The problem is that the plots only get displayed the first time. If they are selected again, nothing shows up. I'm thinking this may be a bug but I could be doing something wrong?
The example above can be rewritten to avoid this issue but I rely on this pattern for something more involved.