【问题标题】:R Shiny - use tabPanel in tabsetPanel dynamicalyR Shiny - 在 tabsetPanel 中动态使用 tabPanel
【发布时间】:2015-08-11 16:24:38
【问题描述】:

我需要动态地将 tabPanel 添加到 tabsetPanel。我在同一个 tabsetPanel 中也有几个常量 tabPanel。我只找到了一种解决方案 (R Shiny - add tabPanel to tabsetPanel dynamically (with the use of renderUI))

我根据这篇文章构建了我的代码。但是现在我无法调用这些 tabPanel 并在那里打印任何信息。

有人可以建议我如何调用我的 tabPanel 或如何组织 tabPanel 的动态使用/添加

library(shiny)


shinyUI(fluidPage(
  title = 'Examples of DataTables',
  sidebarLayout(

    sidebarPanel(
      wellPanel(
        numericInput('crlevel', "Q-ty of criterion levels",2)
      ),
            textOutput("text1"),
           conditionalPanel(
        "input.tabPanel === 'Tab 2'",
      helpText('helptext - Test1'),
      numericInput ("level","Test2. Q-ty of Criterion levels:", 3)
        )  
    ),

    mainPanel(
      uiOutput("mytabs")
    )
  )
))




library(shiny)

 shinyServer(function(input, output,session) {

output$text1 <- renderText({
    paste("The value of input$crlevel is: ", input$crlevel
    )
  })
  output$mytabs <- renderUI({
      do.call(tabsetPanel, lapply(1:(input$crlevel+2), function(x){      
      if (x == 1) {tabPanel("options", textOutput("options"))
      }else {
      tabPanel(paste('Tab', x), uiOutput('Tab', x))
      }
    })
    )
  })  
output$options <- renderText({
  paste("Hello world! "
  )
})
})

【问题讨论】:

    标签: r shiny rstudio tabpanel


    【解决方案1】:

    如果有人感兴趣,我发现错误。这非常简单:

    WRONG tabPanel(paste('Tab', x), uiOutput('Tab', x))
    
    RIGHT tabPanel(paste('Tab', x), uiOutput(paste('Tab', x)))
    

    :-D

    【讨论】:

      猜你喜欢
      • 2013-10-28
      • 2013-05-16
      • 1970-01-01
      • 2013-07-13
      • 2016-07-12
      • 1970-01-01
      • 2014-06-08
      • 2021-01-23
      • 2021-07-06
      相关资源
      最近更新 更多