R Shiny: test existence of reactive value which is optional after req()

I have code like this

myfx <- reactive({
  req(
    isTruthy(input$value),
    isTruthy(data1()) || isTruthy(data2())
  )
  ...
  
  if(exists(data2())) {
    # do some stuff
  }
  ## do this other stuff regardless 
})

the if(exists()) piece is where I am stuck. exists is not the right function here, nor does validate(need(data2())) work. How can i conditionally execute some code if one of the optional reactives (from a group where at least one is required) exists?



Read more here: https://stackoverflow.com/questions/68473529/r-shiny-test-existence-of-reactive-value-which-is-optional-after-req

Content Attribution

This content was originally published by mb158127 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: