Posted By

rlvesco7 on 01/05/10


Tagged

functions lists loops Vector


Versions (?)

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


 / Published in: R
 

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

  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)

Report this snippet  

You need to login to post a comment.