How to avoid a loop in R: selecting items from a list - Stack Overflow


/ Published in: R
Save to your folder(s)



Copy this code and paste it in your HTML
  1. t <- c("bob_smith","mary_jane","jose_chung","michael_marx","charlie_ivan")
  2.  
  3. f <- function(s) strsplit(s, "_")[[1]][1]
  4.  
  5. sapply(t, f)

URL: http://stackoverflow.com/questions/1355355/how-to-avoid-a-loop-in-r-selecting-items-from-a-list

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.