title: Change parameter values at time step in deSolve
body: <p>I am trying to solve an ODE in R using <code>deSolve</code>. With the following code, I expected the parameter <code>gamma0</code> takes the values 5 at time step 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and 10, and 0 otherwise. However, the <code>print(gamma0)</code> shows that <code>gamma0</code> stays at 0. </p>
  
  <p>Here is my ODE: </p>
  
  <pre><code>library(deSolve) 
  param &lt;- c(a = 0.1, b = 1) 
  yini &lt;- c(alpha0 = 6, beta0 = 2) 
  
  mod &lt;- function(times, yini, param) { 
  
    with(as.list(c(yini, param)), { 
  
      gamma0 &lt;- ifelse(times %in% seq(0,10,1), 5, 0) 
  
      ## print(gamma0) 
  
      dalpha0 &lt;- - a*alpha0 + gamma0 
      dbeta0 &lt;- a*alpha0 - b*beta0 
      return(list(c(dalpha0, dbeta0))) 
  
    })} 
  
  times &lt;- seq(from = 0, to = 10, by = 1/24) 
  out &lt;- ode(func = mod, times = times, y = yini, parms = param) 
  plot(out, lwd = 2, xlab = "day")
  </code></pre>
  
  <p>What am I doing wrong?</p>