[R] Splitting a set of vectors in a list
John Kane
jrkrideau at yahoo.ca
Thu Mar 13 19:03:24 CET 2008
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!
More information about the R-help
mailing list