[R] howto find x value where x=max(x)

Richard.Cotton at hsl.gov.uk Richard.Cotton at hsl.gov.uk
Fri May 8 15:05:15 CEST 2009


> 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}}




More information about the R-help mailing list