I've got a vector test <- c(1:90)
(approximately representing 3 months in daily time-steps), I want to give a value to a variable during a run of a model only when the time is between days 10 and 20 in each month:
//model code
if(month-day>10 && month-day<20)
{
parameter <- 10
} else {
parameter <- 5
}
By finding the modulus (test%%30
), I can get an vector containing the days for each month, but need to get the positions of the days 10-20 for each month out of this subsequent vector
> test%%30
[1] 1 2 3 4 [...] 27 28 29 0 1 2 3 ...
I've just hit a brickwall with how to get the values I want (i.e. in this simple example I want test[11:19]
, test[41:49]
and test[71:79]
, but there must be a way to get these values using some clever mathematical operators that I can't think of at the moment...