【问题标题】:Shiny R: conditionalPanel and actionButton闪亮的 R:条件面板和动作按钮
【发布时间】:2016-09-24 12:48:06
【问题描述】:

我很难理解条件面板。

最初,我想显示一个面板,其中包含有关如何使用该应用程序(税收计算器)的说明。一旦用户将输入更改为他们的规格并按下更新,第二个条件面板就会出现。

目前该应用程序在第一轮运行,但随后按钮的计数增加到超过 0 和 1 导致它们无用。

其他帖子建议使用isolate(),我不确定在这种情况下我的意思是隔离。

#buttons

actionButton(inputId = "updateButton",
                        label = "Update"),
           actionButton(inputId = "reset_button",
                        label = "Reset")

#conditional panels

conditionalPanel(
  condition = ("input.updateButton == 0"),
h3("Instructions for calculator"),
),
conditionalPanel(
  condition = "input.updateButton == 1",
  tabPanel(
    "Summary",
      h3("Outputs calculated based on user inputs"),
        )

如果我错过了什么,请告诉我。谢谢。

【问题讨论】:

    标签: r shiny


    【解决方案1】:

    您可以尝试使用这样的余数进行破解:

    第一个条件

    ("input.updateButton%2==0")
    

    第二个条件

    ("input.updateButton%2==1")
    

    【讨论】:

    • 当我有机会使用它时,我会更新我的帖子,经过一点游戏我认为它会起作用。
    【解决方案2】:

    如果使用input.updateButton != 0 作为第二个条件面板的条件呢?

    #buttons
    
    actionButton(inputId = "updateButton",
                            label = "Update"),
               actionButton(inputId = "reset_button",
                            label = "Reset")
    
    #conditional panels
    
    conditionalPanel(
      condition = ("input.updateButton == 0"),
    h3("Instructions for calculator"),
    ),
    conditionalPanel(
      condition = "input.updateButton != 0",
      tabPanel(
        "Summary",
          h3("Outputs calculated based on user inputs"),
            )
    

    【讨论】:

    • 有什么理由不分别用 !input.updateButton 和 ``input.updateButton` 替换 input.updateButton == 0input.updateButton != 0 吗?它们对我来说似乎工作相同,按钮只能有两种状态,对吧?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-04-10
    • 1970-01-01
    • 1970-01-01
    • 2014-03-03
    • 1970-01-01
    • 2017-04-29
    • 2016-01-20
    相关资源
    最近更新 更多