首页 > 解决方案 > 我可以通过在 Shiny 中更改 selectInput 的状态来触发 eventReactive 吗?

问题描述

您能否举个例子来帮助我如何触发 eventReactive 表达式以通过“动作按钮”或通过从 selectInput 中选择另一个项目(而不是默认值)来启动,例如:

DAT<-eventReactive(input$action_button | input$sel_input_menu,{

rest of the code comes here that gets executed whenever I either hit the "actionbutton" or change the state of the selectInput...

})

标签: rshinyshiny-reactivity

解决方案


您需要将两个输入包装起来c(),并将它们作为表达式传递给 in 的第一个参数eventReactive(),如下所示:

DAT<-eventReactive({ c(input$action_button,input$sel_input_menu) },{
        # do some stuff
    })

推荐阅读