[R] Splitting a set of vectors in a list

From: John Kane <jrkrideau_at_yahoo.ca>
Date: Thu, 13 Mar 2008 14:03:24 -0400 (EDT)


I have a set of character vectors of uneven length that I have stored in a list. I can easily enough get any column of them using lapply but what I want is to be able to create a matrix of them. Other than some kind of brute force looping approach I have drawn a blank.

Would somebody please suggest something? Thanks  

Example.

mylist <- list(aa=c("cat","peach" ), bb=c("dog", "apple", "iron"),

         cc = c("rabbit", "orange", "zinc", "silk"))
myfun <- function(dff) dff[1]       

vect1 <- unlist(lapply(mylist, myfun))

      Looking for the perfect gift? Give the gift of Flickr!



R-help_at_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. Received on Thu 13 Mar 2008 - 18:19:58 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 13 Mar 2008 - 19:30:34 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive