【问题标题】:how to acheive conditional output based on tab selection in shiny app如何根据闪亮应用程序中的选项卡选择实现条件输出
【发布时间】:2018-06-01 04:29:09
【问题描述】:

我想在侧边栏“otu selection”和“anova”中有 2 个选项卡。 根据在侧边栏中选择的选项卡,我想在主面板中输出不同的图表或表格。

目前我收到一个错误:

ERROR: object 'input.tabs' not found

这是我的脚本。

ui <- fluidPage(
  # Make a title to display in the app
  titlePanel(" Exploring the Effect of Metarhizium on the Soil and Root Microbiome "),
  # Make the Sidebar layout
  sidebarLayout(
    # Put in the sidebar all the input functions
    sidebarPanel(
      tabsetPanel(id="tabs",
        tabPanel("otu","OTU selection", selectInput('dataset', 'dataset', names(abundance_tables)),
                 uiOutput("otu"), br(),
                 # Add comment
                 p("For details on OTU identification please refer to the original publications")),
        tabPanel("anova","anova", sliderInput('pval','p-value for significance',
                                      value=5,min=0,max=0.5,step=0.00001),
                 selectInput('fact_ofInt','factor of interest',FactorsOfInt))
        )
    ),
    # Put in the main panel of the layout the output functions 
    mainPanel(
      conditionalPanel(condition=input.tabs == 'otu',
        plotOutput('plot')
     #   dataTableOutput("table")
      ),
     conditionalPanel(condition=input.tabs == 'anova',
                      plotOutput('plot2')
                      #   dataTableOutput("table")
     )
    )
  )
)

我看过类似的帖子,但仍需要一些指导。

谢谢

【问题讨论】:

    标签: shiny


    【解决方案1】:

    您的条件面板条件以错误的格式声明。 正确的格式是

     # Put in the main panel of the layout the output functions 
        mainPanel(
          conditionalPanel(condition=input.tabs == 'otu',
            plotOutput('plot')
         #   dataTableOutput("table")
          ),
         conditionalPanel(condition="input.tabs == 'anova'",
                          plotOutput('plot2')
                          #   dataTableOutput("table")
         )
        )
    

    所以条件语句总是在 "" 中赋值,而在 "" 中则执行相等性检查。

    【讨论】:

    • 太棒了。谢谢。您的解决方案错过了 input.tabs == otu 条件周围的“”。
    猜你喜欢
    • 1970-01-01
    • 2017-11-30
    • 1970-01-01
    • 2013-07-04
    • 2018-06-18
    • 2021-07-14
    • 1970-01-01
    • 2018-06-20
    • 1970-01-01
    相关资源
    最近更新 更多