[R] howto find x value where x=max(x)
Lasse Bombien
lasse at phonetik.uni-muenchen.de
Fri May 8 15:03:14 CEST 2009
Hi,
you could use which.max().
> fp$Frequenz[which.max(fp$AmpNorm)]
I found the reference in the max() help.
Lasse
Am Freitag, den 08.05.2009, 14:49 +0200 schrieb Jonas Stein:
> Hi,
>
> fp is a data frame like this
>
> ,----[ fp ]
> | Frequenz AmpNorm
> | 1 3322 0.0379490639
> | 2 3061 0.0476033058
> | 3 2833 0.0592954124
> | 4 2242 0.1275510204
> `----
>
> i want to find the "Frequenz" where "AmpNorm" is max.
>
> I use this line as workaround:
> PeakFreqHz = subset(fp, AmpNorm == max(AmpNorm))$Frequenz[1]
>
> Is there something nicer?
> And is there an easy way to do the same on "predict()"
>
> Thank you and kind regards,
>
--
Lasse Bombien
Institut für Phonetik und Sprachverarbeitung
Schellingstraße 3/II
D-80799 München
email: lasse at phonetik.uni-muenchen.de
web: http://www.phonetik.uni-muenchen.de/~lasse
phone: +49 (0) 89 2180 2812
More information about the R-help
mailing list