0

I apologize for not having a specific reproducible example, and I hope my question is not too generic.

I was wondering whether it is possible in R shiny to use reactiveValues() to remove a plotOutput object. In particular, can I have something like

my_values <- reactiveValues(A = my_plot, B = [something])

if (condition)
{
  output$my_plotOutput <- my_values$A

} else 

{
  output$my_plotOutput <- my_values$B
}

Where the latter option eliminates (or just renders invisible) the plotOutput?

I know I can make the plot NULL, but then the empty rectangle remains.

Thanks in advance.

John Smith
  • 393
  • 1
  • 6
  • 17
  • To *render invisible*, you might use [`shinyjs::hide`](https://github.com/daattali/shinyjs); [`shiny::removeUI`](http://shiny.rstudio.com/reference/shiny/latest/removeUI.html) (perhaps overkill, you'd then need `insertUI` to put it back in); or just `plot(0, type='n', axes=FALSE, ann=FALSE)` (a plot with nothing). – r2evans Jun 20 '17 at 15:56

1 Answers1

0

Have you tried the conditionalPanel ? Please refer to conditionalPanel Document

In server.R:

output$plotUI <- renderUI({
   conditionalPanel(condition=YOURCONDITION,
                    YOURPLOT)
})

In ui.R:

uiOutput("plotUI')
ssword
  • 905
  • 10
  • 13