I'm attempting to add a variable number of plots to a page.
With each page I add, I'd also like to add some control boxes. Adding all of this to the page isn't the problem, the problem arises when i attempt to use the input boxes to control the plots. the input values aren't recognized inside the plot definitions.
How can I make this work?
runApp(list(
ui = shinyUI(
bootstrapPage(
numericInput('n.plots', "Number of Plots", 2),
uiOutput('plots')
)
),
server = shinyServer(function(input, output, session){
for(i in 1:max.plots){
local({
my.i <- i
plotname <- paste('plot',my.i, sep = '')
output[[plotname]] <- renderPlot({
# Work in plot (not reactive though)
# hist(rnorm(100, input[[paste('mean_', my.i)]], input[[paste('sd_', my.i)]]))
# Doesn't work
hist(rnorm(100, input[[paste('mean_', my.i)]], input[[paste('sd_', my.i)]]))
})
})
}
output$plots <- renderUI({
out <- ''
for(i in 1:input$n.plots){
additional <- fluidRow(
column(width = 4,
wellPanel(
h5(paste('Thing', i)),
numericInput(paste('mean_',i, sep = ''), 'Mean', 100),
numericInput(paste('sd_', i, sep = ''), 'SD', 25)
)
),
column(width = 8,
plotOutput(paste('plot',i, sep = ''))
)
)
out <- paste(out, additional)
}
HTML(out)
})
})
)
)