[R] How to find values that correspond to a given value (i.e. max)

Hal_V Tim.Umbach at hufw.de
Wed Sep 18 21:42:36 CEST 2013


Hi everyone
I'm new to R, so this is probably a stupid question, but I looked around for
quite a while an couldn't find an answer. Basically I'm trying to print
values that correspond to a found maximum.

If I have this:

"names" <- c("John", "Jim", "Mary", "Susan")
"age" <- c(16, 25, 32, 56)
"income" <- c(2000, 3000, 2500, 1500)
"all"<- data.frame(names, age, income)
max(all$income)

I would like to print the name and age that correspond to the found maximum.
I tried some if-statements, but they didn't work because my programming
skills outside of SQL are basically non-existent.

I'd be glad for any pointers, thanks



--
View this message in context: http://r.789695.n4.nabble.com/How-to-find-values-that-correspond-to-a-given-value-i-e-max-tp4676456.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list