R Shiny:带有两个控件的 eventReactive

Pau*_*ers 2 r shiny

我有以下 R Shiny 代码:

  economics_points <- eventReactive(input$sigmaThresholdSlider, {
    print("input$sigmaThresholdSlider fired.")
    get_points(input$daterange, 1, input$sigmaThresholdSlider)
  }, ignoreNULL = FALSE)
  economics_points <- eventReactive(input$daterange, {
    print("input$daterange fired.")
    get_points(input$daterange, 1, input$sigmaThresholdSlider)
  }, ignoreNULL = FALSE)
Run Code Online (Sandbox Code Playgroud)

问题是economics_points只有在daterange控件更改时才更新,而不是在sigmaThresholdSlider控件更改时更新。如果我颠倒两个语句的顺序,economics_points则仅在sigmaThresholdSlider移动时更新。换句话说,第二条语句覆盖了第一条语句。

如何更改此代码,使其在调整任一控件时运行?

文件说,eventExpr的参数eventReactive可以是“连花括号内复杂的表达式”,但没有有用的例子给出。

mRc*_*ing 5

通过给出一个列表,它似乎有效:

服务器

library(shiny)

shinyServer(function(input, output) {

  view <- eventReactive(list(input$t1, input$t2),{
      t1 <- input$t1              
      t2 <- input$t2

      rnorm(1)
  })

  output$view <- renderPrint(view())

})
Run Code Online (Sandbox Code Playgroud)

用户界面

library(shiny)

shinyUI(fluidPage( 

  sidebarLayout(
    sidebarPanel(
      actionButton("t1", "t1"),
      actionButton("t2", "t2")
    ),


    mainPanel(
      verbatimTextOutput("view")
    )
  )
))
Run Code Online (Sandbox Code Playgroud)