Skip to content
Prev 318632 / 398506 Next

if value is in vector, perform this function

On 03-03-2013, at 00:57, Louise Stevenson <louise.stevenson at lifesci.ucsb.edu> wrote:

            
You have been given a correction for expression for (t %in% feed_days).

But even with that correction things will not do as you seem to want.

The argument "t" of function Daphnia is the integration time the ode solver is passing and almost certainly is NOT an element of the vector t defined at the start of your script. That "t" is the "the time sequence for which output is wanted" (see ode help); it is what is put into the output of ode.
There is no reason to assume that the Daphnia argument t is  an element of feed_days. You can easily check this by inserting a print(t) in Daphnia. So C_A will be 0 most of the time.

It would certainly help if you named the elements of the init vector and the return list of Daphnia.
In Daphnia x[2] is C_D. But what is x[1] (C_A?)?

I think you will have to look at deSolve events but I'm not sure if that is possible or required/desired with your model.

Berend