[R] Efficient way to parse string and construct data.frame

yoooooo magno_yu at ml.com
Tue Aug 28 17:32:55 CEST 2007


Hi all, 

I have this list of strings
[1] "1 ,2 ,3"  "4 ,5 ,6"

Is there an efficient way to convert it to data.frame:
   V1  V2  V3
1   1   2    3
2   4   5    6

Like I can use strsplit to get to a list of split strings.. and then use say
a = strsplit(mylist, ",")
data.frame(V1 = lapply(a, function(x){x[1]}), V2 = lapply(a,
function(x){x[2]}),.....)

but i'm loop through that list so many times.. so I'm hesitated to use
that.. 

Thanks a lot for your great help before and this time as well!! 
- boy....
-- 
View this message in context: http://www.nabble.com/Efficient-way-to-parse-string-and-construct-data.frame-tf4342441.html#a12370234
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list