Hello everyone,
My ui looks like this:
ui <- fluidPage(
## Also contains many input elements
plotOutput("hist1"), plotOutput("hist2"), plotOutput("hist3"),
plotOutput("hist4"), plotOutput("hist5"), plotOutput("hist6"),
plotOutput("hist7"), plotOutput("hist8"), plotOutput("hist9"),
plotOutput("hist10"), plotOutput("hist11"), plotOutput("hist12"),
plotOutput("hist13"), plotOutput("hist14"), plotOutput("hist15"),
plotOutput("spatial1"), plotOutput("spatial2"), plotOutput("spatial3"),
plotOutput("spatial4"), plotOutput("spatial5"), plotOutput("spatial6"),
plotOutput("spatial7"), plotOutput("spatial8"), plotOutput("spatial9"),
plotOutput("spatial10"), plotOutput("spatial11"), plotOutput("spatial12"),
plotOutput("spatial13"), plotOutput("spatial14"), plotOutput("spatial15"),
verbatimTextOutput("finalstatus")
)
I have a segment of code at the end:
drawFinalPlots <- reactive({
for(j in 1:length(deconvolute()[[1]])) {
histID <- paste("hist", j, sep = "")
spatialID <- paste("spatial", j, sep = "")
output[[histID]] <- renderPlot(deconvolute()[[1]][[j]])
output[[spatialID]] <- renderPlot(deconvolute()[[2]][[j]])
# print(deconvolute()[[2]][[j]])
}
"done"
})
output$finalstatus <- renderText(drawFinalPlots())
The reactive expression deconvolute() is a list of two lists. Each of these sub-lists contains nine ggplot2 objects. However, when my entire app is run, the outputted plots to the hist1, hist2...hist9 and spatial1...spatial9 are only the ninth plots in each of the two lists. In other words, all the outputs hist1...hist9 are outputting the plot located at deconvolute()[[1]][[9]], and the outputs spatial1...9 are outputting the plot at deconvolute()[[2]][[9]].
I tried using the line print(deconvolute()...) (the commented line above) to see if the plots in the returned expression were messed up. Printing them to the RStudio plot pane showed that all of the plots were stored properly (it printed out all the plots I wanted) for both lists in deconvolute(). Yet Shiny seems to only access the last plot in each of the two lists. Why might this be happening?
I'd prefer not to post my entire code here, but if we can't figure this out I'd be happy to DM it to someone.
Thanks!