I'd like to create dynamical tabs/plots in shiny with user input number of tabs/plots
Following Winston Chang's example https://gist.github.com/wch/5436415/
I was able to create both ui and server end functions correctly. My server function is enclosed in a function module, so I need to use namespace to enclose the ui elememt id, but this seems cause the issue that all my dynamical plots do not show in their corresponding tabs.
For example, if my code look like this, it does NOT show the plots
for (i in 1:input$n) {
local({
my_i <- i
plotname <- paste0("TabPlot", my_i) # I tried session$ns(paste0("TabPlot", my_i)), but it does not work as well.
output[[plotname]] <- renderDygraph({
return(some dygraph)
})
})
}
But if my code looks like this, it shows the plots
output$TabPlot1 <- renderDygraph({
return(some dygraph)
})
output$TabPlot2 <- renderDygraph({
return(some dygraph)
})
But certainly, in this way, I cannot make it dynamical.
Any suggestion regarding to the namespace issue? Thanks!
-------------Update-------------------
I've put the entire for loop in a reactive environment, say observerEvent(input$Submit, {for loop}) and it works.