Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data<-data.frame(NAMES=replicate(100, paste(sample(letters, 8, replace=T), collapse="")), AGES=sample(20:60, 100, replace=T))
- head(data)
- NAMES AGES
- 1 oepefudt 21
- 2 ibmuaemm 49
- 3 mkockaqu 23
- 4 whyzomna 59
- 5 omqqtbsz 35
- 6 qnbmjmuf 25
- sort(as.character(data$NAMES[data$AGES==max(data$AGES)]))
- # Find the maximum age
- max.age<-max(data$AGES)
- # Which rows have the maximum age value?
- ind<-which(data$AGES==max.age)
- # Extract the name using the ind from above
- persons<-as.character(data$NAMES[ind])
- # Sort the names
- persons.sorted<-sort(persons)
- persons.sorted
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement