Re: [R] Converting strings with internal delimiters into lists

From: Berton Gunter <gunter.berton_at_gene.com>
Date: Fri 12 Aug 2005 - 03:58:42 EST


??? I guess I don't get it.

Note that

> testtable<-
>

as.data.frame(cbind(c("Joe,Mary,Jane","Mary"),c("Fred,Joe","Pete,Joe,Mary,Fr ed")))

is probably not what you want since cbind expects vectors of equal length. By default, shorter vectors are recycled to the length of the longest one, which I doubt is what you want.

Why isn't

>

mylist<-list(c("Joe,Mary,Jane","Mary"),c("Fred,Joe","Pete,Joe,Mary,Fred"),.. .)

suitable? S lists are specifically designed to handle different objects with different lengths (or totally different objects). lapply(), sapply() and friends or for() loops can then work over such a list to do what you want.

"The business of the statistician is to catalyze the scientific learning process." - George E. P. Box



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Aug 12 04:04:35 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 15:15:07 EST