Error. Object not found.

The following is my code script:

library(ggplot2)
library(deSolve)

model <- function(times, state, parameters) {
dS <- parameters["r_max"] * (1 - state["S"]/parameters["K"]) *
state["S"] - parameters["c"] * state["S"]
return(list(c(dS))) }

parameters <- c(r_max = 0.5, K = 200, c = 0.2)

init_state <- c(S = 1)

solution <- ode(y= init_state, times = times, func = model, parms = parameters)

ggplot(as.data.frame(solution), aes(x = time, y = S)) + xlab("t") +
ylab("S(t)") + geom_line(size = 1.1)

Everything works fine except I get the following message when I try to run:
Error in checkInput(y, times, func, rtol, atol, jacfunc, tcrit, hmin, :
object 'times' not found

How might I fix this?

Provide an object called times before you pass it

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.