Thanks Gabor. Your suggestions work as well and have been helpful in my
understanding, I can't use any excuse of not knowing about "]" in this
case!
Rob
fil3 = sapply(ls1, function(x) paste(x[1:4], collapse = ""))
fil4 = sapply(unname(as.data.frame(ls1))[1:4,], paste, collapse = "")
fil5 = sapply(as.data.frame(ls1)[1:4,], paste, collapse = "")
What I want to end up with is a vector that is the row-wise concatenation
of
the strings in each row of your matrix or each element of my original
list.
Try this:
sapply(ls1, function(x) paste(x[1:4], collapse = ""))
or this:
sapply(unname(as.data.frame(ls))[1:4,], paste, collapse = "")
If you don't mind ugly names on the result the last one can be shortened
to:
sapply(as.data.frame(ls)[1:4,], paste, collapse = "")
--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com
______________________________________________
R-help@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.