zack holden:
> I need to sort through a vector (x) and identify the point at which 2
> successive values become smaller than the previous value.
x <- c(5,5,7,6,5,4,3)
a=c(diff(x, 1) < 0, FALSE) & c(diff(x, 2) < 0, FALSE, FALSE)
a # FALSE FALSE TRUE TRUE TRUE FALSE FALSE
which(a) # 3 4 5
Does this give the answer that you want?
> x <- c(5,5,7,6,5,4,3)
> result <- NULL
> for (i in 1:(length(x) - 2)){
+ if ((x[i + 1] < x[i]) && (x[i + 2] < x[i])) result <- c(result, i)
+ }
> result
[1] 3 4 5
>
On 2/29/08, zack holden <[EMAIL PROTECTED]> wrote:
>
> Dear list,
> I'm trying to w
2 matches
Mail list logo