[R] which.minimums not which.min
Liaw, Andy
andy_liaw at merck.com
Wed Mar 15 21:23:29 CET 2006
What you want seems to be the valleys and peaks in the data. If so, try:
RSiteSearch("find peaks")
which points to a post by Philippe Grosjean, pointing to the pastesc
package:
> library(pastecs)
Loading required package: boot
> tp <- turnpoints(x)
> which(tp$peaks)
[1] 4 10
> which(tp$pits)
[1] 5 11
Andy
From: Fred J.
>
> Hi
>
> Is there a function which determines the location, i.e.,
> index of the all minimums or maximums of a numeric vector.
> Which.min(x) only finds the (first) of such.
>
> > x <- c(1:4,0:5, 4, 11)
> > x
> [1] 1 2 3 4 0 1 2 3 4 5 4 11
> > which.min(x)
> [1] 5
> > which.max(x)
> [1] 11
> >
>
> but I need
> which.min(x) to be 5 11
> which.max(x) to be 4 10
>
> thanks
>
>
> __________________________________________________
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
>
More information about the R-help
mailing list