Title says it basically. For a complex Shiny App I have to be able to send NULL values to renderPlotly()
, because I want to display a plot only when certain conditions are met. The normal shiny::renderPlot()
is able to do this.
A small example which gives an error I do not want:
library(shiny)
library(plotly)
ui <- fluidPage(
plotlyOutput("plotly"),
plotOutput("plot")
)
server <- function(input, output) {
# I need to be able to put NULL in here or anything so that
# there is no output and also no error message.
output$plotly <- renderPlotly({
NULL
})
# This works and sends no error message
output$plot <- renderPlot({
NULL
})
}
shinyApp(ui, server)
Note that the Web App displays only one error message, the one from renderPlotly()
.
I am looking for any workaround to this. How can I switch between those two plots which should be displayed at the same spot in the app, and always ignore one of them, depending on other input?