On Apr 26, 2010, at 12:29 PM, Su Chu wrote:
Hi there,
I am working on a project that requires me to find the point at
which values
become negative in a sequence about the max.
For example, say I have some sequence:
x=c(-12, -2,-19, 0, -14, -2, 9,10,20,35,56,89,60,39,12,8,-5,-2,0,10)
> x[ c( which.max(x) -min(which(x[which.max(x):1] < 0)) +1,
+ which.max(x) +min(which(x[which.max(x):length(x)] < 0)) -1) ]
[1] -2 -5
In this sequence, the max is 89, and I need to identify that -2 and
-5 are
the points at which the values* first *become negative about the max
and
retrieve their index values.
I was hoping for some help in finding a way to automate this
procedure, as I
have over 100 vectors of this kind where I must find the two values
about
the max.
Could anyone help? I would really, really appreciate it!
Thank you so much!
Best,
Su
[[alternative HTML version deleted]]
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
David Winsemius, MD
West Hartford, CT
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.