Re: [R] Trying to avoid loop structure

2010-09-29 Thread Phil Spector
Mathieu - First of all, you can combine as many conditions as you want in an if statement, using && (and) and || (or). So to say coef$st[i-1] < obs[t] < coef$st[i] use coef$st[i-1] < obs[t] && obs[t] < coef$st[i] So following your logic, you could use x = numeric(length(obs)) for(t

[R] Trying to avoid loop structure

2010-09-29 Thread Mathieu Beaulieu
Dear R-helpers, I'm trying to associate linear coefficients (intercept and slope) to tens of thousands of observations based on a table with benchmark values. #Example - Value table and their corresponding coefficients (intercept and slope) coef = data.frame(cbind(st=c(1:5),b = runif(5,0.3,5