Hi, Try: all[which.max(all$income),c('names','age')] # names age #2 Jim 25
A.K. 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 ______________________________________________ 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.