Advertisement
Guest User

Untitled

a guest
Jul 30th, 2014
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. data<-data.frame(NAMES=replicate(100, paste(sample(letters, 8, replace=T), collapse="")), AGES=sample(20:60, 100, replace=T))
  2. head(data)
  3.  
  4. NAMES AGES
  5. 1 oepefudt 21
  6. 2 ibmuaemm 49
  7. 3 mkockaqu 23
  8. 4 whyzomna 59
  9. 5 omqqtbsz 35
  10. 6 qnbmjmuf 25
  11.  
  12. sort(as.character(data$NAMES[data$AGES==max(data$AGES)]))
  13.  
  14. # Find the maximum age
  15. max.age<-max(data$AGES)
  16. # Which rows have the maximum age value?
  17. ind<-which(data$AGES==max.age)
  18. # Extract the name using the ind from above
  19. persons<-as.character(data$NAMES[ind])
  20. # Sort the names
  21. persons.sorted<-sort(persons)
  22. persons.sorted
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement