1
我想動態地插入一些閃亮的應用程序中的情節。我已經將這個簡化爲一個簡單的例子,它顯示了三個具有相同數量的箱(48)的直方圖,即使它們應該不同(16,32,48)。可能我做了一些非常愚蠢的事情,或者錯過了更微妙的東西!代碼附加。預先感謝任何暗示。Shiny動態用戶界面中的多個地塊
shinyUI(fluidPage(tagList(
actionButton("button_id", "Show plot"),
uiOutput("plot_id"),
HTML("<div id=\"end\">The end</div>"))))
shinyServer(function(input, output) {
# A list to hold the plot IDs
ls <- list()
observeEvent(input$button_id,
{
x <- faithful[, 2]
for (i in 1:3)
{
# generate bins based on input$bins from ui.R
count <- i * 16
bins <- seq(min(x), max(x), length.out = count)
ls[[i]] <<- paste0("plot_", i)
output[[ls[[i]]]] <- renderPlot(hist(x, breaks = bins, col = 'darkgray', border = 'white'))
}
output$plot_id <- renderUI({
wellPanel(do.call(tagList, lapply(ls, function(x)
{
plotOutput(x)
})))
})
})
})
做了我解決方案? – AEF