What does the error message "cannot coerce type 'closure' to vector of type 'any'" mean?

2,327 views
Skip to first unread message

vac...@kenyon.edu

unread,
Mar 21, 2017, 3:25:12 PM3/21/17
to Shiny - Web Framework for R
Hi everyone, 
I am relatively new to Shiny, but I'm working under a tight deadline and I'm very stuck. I am getting the error message "cannot coerce type 'closure' to vector of type 'any'." Can anyone give me insight into what this means? For more background, I am running a SIR epidemic model, which requires the desolve package. This seems to be the section of code that's giving me trouble (in my server component). I am not sure exactly where the problem is, but any help would be greatly appreciated. 

times <- seq(0, 150, by = 1)
  out <-reactive({
    out<-renderDataTable(ode(y= init, times = times, func = sirvac, parms = parameters))
  })

output$curves<- renderPlot({
  matplot(times, out(), type = "l", xlab = "Time", ylab = "Susceptibles and Recovereds", main = "SIR Model", lwd = 1, lty = 1, bty = "l", col = 2:4)
  legend(40, 0.7, c("Susceptibles", "Infecteds", "Recovereds"), pch = 1, col = 2:4)
  })

Thank you!!
-Emily

Joe Cheng

unread,
Mar 21, 2017, 4:19:15 PM3/21/17
to vac...@kenyon.edu, Shiny - Web Framework for R
Your `out` reactive is wrong--renderDataTable should never be used for anything other than being assigned to output$something. I don't know what "ode" is, but I assume it should be like this?

out <- reactive({
  ode(y= init, times = times, func = sirvac, parms = parameters)
})

but are there supposed to be any reactive inputs or whatever referred to in there?

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/b99e01ef-494c-4e39-97e4-6a0fa4f99ad2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages