I have a 65k element character vector, of the format. The length of each element is different, but ranges from 3 to 8 based on commas.:
b[1]= "aaaa, bbbb, cccc"
...
b[1000]="aaaa, bbbb, cccc, dddd, eeee, ffff"
...
b[3000]="aaaa, bbbb, cccc, dddd, eeee, ffff, gggg"
b[3001]="aaaa, bbbb, cccc"
I want to convert to a data frame:
row col1 col2 col3 col4 col5 col6 col7
1 aaaa bbbb cccc
1000 aaaa bbbb cccc dddd eeee ffff
3000 aaaa bbbb cccc dddd eeee ffff gggg
I tried:
data.frame( do.call( rbind, strsplit( b, ',' ) ) )
and got:
Warning message: In (function (..., deparse.level = 1) : number of columns of result is not a multiple of vector length (arg 1)
Any suggestions?