Skip to content
Prev 183 / 15274 Next

syntax for a loop

Create lagged vectors:

# corresponds to x.dif[i-1]
lag.minus1 <- c(NA,x.dif[-length(x.dif)])

# corresponds to x.dif[i+2]
lag.plus2 <- c(x.dif[-c(1,2)],NA,NA)

Then create a true/false vector:

selected.rows <- lag.minus1 <= 0 && x.dif > 0 && lag.plus2 > 0

Those indices you want will then have TRUE values.
To see row positions in x.dif, use the command

(1:length(x.dif))[selected.rows]


---------- Original Message ----------------------------------
From: ebashi <arshia22@yahoo.com>
Date:  Sun, 28 Nov 2004 03:20:22 -0800 (PST)