Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 直接向闪亮的仪表板动态添加框_R_Shiny_Shinydashboard - Fatal编程技术网

R 直接向闪亮的仪表板动态添加框

R 直接向闪亮的仪表板动态添加框,r,shiny,shinydashboard,R,Shiny,Shinydashboard,我正在尝试根据向量的内容向闪亮的界面添加多个框 让我们从这里开始: library(shiny) ui <- fluidPage( titlePanel("Dynamic Boxes"), fluidRow( uiOutput("boxes") ) ) server <- function(input, output) { output$boxes <- renderUI({ interf <- "" for(i i

我正在尝试根据向量的内容向闪亮的界面添加多个框

让我们从这里开始:

library(shiny)

ui <- fluidPage(

   titlePanel("Dynamic Boxes"),

   fluidRow(
     uiOutput("boxes")
  )
)

server <- function(input, output) {

  output$boxes <- renderUI({
    interf <- ""
    for(i in 1:10){
      x = 1:100
      interf <- box(title = paste0("box ", i), 
          renderPlot(plot(x = x, y = x^i)))

    }
    interf
  })
}

shinyApp(ui = ui, server = server)
库(闪亮)

ui
来自您尚未加载的
shinydashboard
软件包(至少在您的帖子中)。无论如何,您需要一个for循环不创建的box元素列表。这里有一条路-

library(shiny)
library(shinydashboard)

ui <- fluidPage(      
  titlePanel("Dynamic Boxes"),      
  fluidRow(
    uiOutput("boxes")
  )
)

server <- function(input, output) {      
  output$boxes <- renderUI({
    lapply(1:10, function(a) {
      x = 1:100
      box(title = paste0("box ", a), renderPlot(plot(x = x, y = x^a)))
    })
  })
}

shinyApp(ui = ui, server = server)
库(闪亮)
图书馆(shinydashboard)

ui的可能复制是否可以使用闪亮的模块概念来实现这一点?你能举个例子吗?