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, -- Jonas Stein <news at jonasstein.de>
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
try this: with(fp, Frequenz[which.max(AmpNorm)]) baptiste On 8 May 2009, at 14:49, Jonas Stein wrote:> 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, > > -- > Jonas Stein <news at jonasstein.de> > > ______________________________________________ > R-help at 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._____________________________ Baptiste Augui? School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag
> 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.Use which.max. fp <- data.frame(Freqenz=c(3322,3061,2833,2242), AmpNorm=c(0.0379,0.0476,0.0592,0.1276)) index.of.max <- which.max(fp$AmpNorm) fp$Freqenz[index.of.max] Regards, Richie. Mathematical Sciences Unit HSL ------------------------------------------------------------------------ ATTENTION: This message contains privileged and confidential inform...{{dropped:20}}
Dear Jonas, Try this: with(fp, Frequenz[ which.max(AmpNorm) ] ) HTH, Jorge On Fri, May 8, 2009 at 8:49 AM, Jonas Stein <news@jonasstein.de> wrote:> 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, > > -- > Jonas Stein <news@jonasstein.de> > > ______________________________________________ > 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. >[[alternative HTML version deleted]]