I created a shiny application with many tabs, in which, each tab corresponds to a dataframe inside a list (called in the example below my.data). Since all tabs have the same initial plot, I created a generic plot function and I pass to it the name of the item it should plot (my.data[[item.name]]).
The problem that I am facing is that when I switch tabs, the item.name passed as a parameter to the create_plot function is not correct. It always passes the last item of the list. I am assuming this happens because the variable is not reactive, but I am don't how to solve this.
server <- function(input, output) {
for(item.name in names(my.data)) {
adjusted.name <- gsub('-', '.', gsub(' ', '.', tolower(item.name), fixed = T))
output[[paste0('plot.', adjusted.name)]] <- renderPlot(create_plot(input, item.name))
}
}