rstudio / flexdashboard

Easy interactive dashboards for R
https://pkgs.rstudio.com/flexdashboard/
Other
812 stars 301 forks source link

Warning: Error in renderFunc: argument "name" is missing, with no default #406

Closed nipnipj closed 1 year ago

nipnipj commented 1 year ago

Here, I'm using fable package. When trying to plot forecast object from:

fit_fc <- eventReactive(input$apply,{
    names <- dat() %>% names()
    dat() %>%
      model(
        ARIMA = ARIMA(response)
      ) %>%
      forecast(h = paste0(input$Input3," years"))
  })

  p3 <- eventReactive(input$apply,{ 
    fit_fc() %>%
    autoplot(
      dat(),
      level = 80,
      alpha = 0.5) +
      labs(title = paste0(input$Input4," Forecast"))
  })

  forecast <- renderPlot(
    p3()
  )

I get the following error.

Warning: Error in renderFunc: argument "name" is missing, with no default
  266: renderFunc
  265: forecast
  218: filter
  217: autoplot
  215: eventReactiveValueFunc [<text>#76]
  213: valueFunc
  200: func
  198: f
  197: Reduce
  188: do
  187: hybrid_chain
  186: <reactive:eventReactive(input$apply)>
  185: .func
  182: contextFunc
  181: env$runWith
  174: ctx$run
  173: self$.updateValue
  171: p3
  170: renderPlot
  168: func
  128: drawPlot
  114: <reactive:plotObj>
   98: drawReactive
   85: renderFunc
   84: output$out4d8087e97bc7da7a
    3: <Anonymous>
    1: rmarkdown::run

Other plots work fine.

gadenbuie commented 1 year ago

Hi @nipnipj, thanks for the report. I don't see anything in your example that seems obviously incorrect, but I also don't see anything that indicates how flexdashboard might be involved in your issue. If you could provide more context in the form of a minimal reproducible example, we'd be happy to take a look.

cpsievert commented 1 year ago

The problem lies with

forecast <- renderPlot(
    p3()
)

renderPlot() may only be assigned to an output slot (e.g., output$forecast). Also keep in mind, in an flxedashboard/rmarkdown document, assigning to an output slot will only work if there is a corresponding output container with a matching id (e.g., plotOutput("forecast")).

That said, you can also just do renderPlot(p3()) (without assigning it to anything) if you just want to render the plot at that particular code chunk location.