Hillary Sanders Hillary Sanders - 5 months ago 40
R Question

How to listen for more than one event expression within a Shiny eventReactive handler

I want two different events to trigger an update of the data being used by various plots / outputs in my app. One is a button being clicked (

) and the other is a point on a dot being clicked (

Basically, I want to listed for both at the same time, but I'm not sure how to write the code. Here's what I have now:

in server.R:

data <- eventReactive({mainplot.click$click | input$spec_button}, {
# get data relevant to the button
} else {
# get data relevant to the point clicked

But the if-else clause doesn't work

Error in mainplot.click$click | input$spec_button :
operations are possible only for numeric, logical or complex types

--> Is there some sort of action-combiner function I can use for the
mainplot.click$click | input$spec_button


Here's the solution I came up with: basically, create an empty reactiveValues data holder, and then modify its values based on two separate observeEvent instances.

  data <- reactiveValues()
  observeEvent(input$spec_button, {
    data$data <- get.focus.spec(input=input, premise=premise, 
                                itemname=input$dropdown.itemname, spec.info=spec.info)
  observeEvent(mainplot.click$click, {
    data$data <- get.focus.spec(input=input, premise=premise, mainplot=mainplot(),