> sapply(a, "[", 1) [1] "John" "Jane" "koda" "gunner" > sapply(a, "[", 2) [1] "Smith" "Doe" NA NA ------------------------------------------------------------------- Jacques VESLOT
CNRS UMR 8090 I.B.L (2ème étage) 1 rue du Professeur Calmette B.P. 245 59019 Lille Cedex Tel : 33 (0)3.20.87.10.44 Fax : 33 (0)3.20.87.10.31 http://www-good.ibl.fr ------------------------------------------------------------------- cory a écrit : > Suppose I have the following list: > > a <- strsplit(c("John;Smith", "Jane;Doe", "koda", "gunner"), ";") > > I want to get to these two vectors without looping... > > firstNames: c("John", "Jane", "koda", "gunner") > lastNames: c("Jane", "Doe", NA, NA) > > Thanks > > cn > > [[alternative HTML version deleted]] > > ______________________________________________ > 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 > and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ 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 and provide commented, minimal, self-contained, reproducible code.