Re: [R] if value is in vector, perform this function

2013-03-03 Thread Patrick Burns
I think the command you want is: if(t %in% feed_days) C_A - 1.5 else C_A - 0 Do not confuse `%in%` (which is essentially are the left-hand values in the right-hand vector) with in of the `for` loop. By the way, if(t == TRUE) is redundant -- better is: if(t) Pat On 02/03/2013 23:57,

Re: [R] if value is in vector, perform this function

2013-03-03 Thread Berend Hasselman
On 03-03-2013, at 00:57, Louise Stevenson louise.steven...@lifesci.ucsb.edu wrote: Hi, I'm trying to set up R to run a simulation of two populations in which every 3.5 days, the initial value of one of the populations is reset to 1.5. I'm simulation an experiment we did in which we fed

Re: [R] if value is in vector, perform this function

2013-03-03 Thread Patrick Burns
I forgot to say: Also do not depend on equality in this situation. You want to test equality with a tolerance. See Circle 1 of 'The R Inferno': http://www.burns-stat.com/documents/books/the-r-inferno/ I also see that 't' is a vector unlike what I was thinking before, thus you want to use

[R] if value is in vector, perform this function

2013-03-02 Thread Louise Stevenson
Hi, I'm trying to set up R to run a simulation of two populations in which every 3.5 days, the initial value of one of the populations is reset to 1.5. I'm simulation an experiment we did in which we fed Daphnia populations twice a week with algae, so I want the initial value of the algal