Re: [R] Cumulative split of value in data frame column

2020-06-05 Thread Bert Gunter
This is a **plain text list **. In future please post in plain text so that your post does not get mangled. Anyway,... I don't know about "efficient, optimized", but here's one simple way to do it using ?strsplit to unsplit and then ?paste to recombine: df <- data.frame(ID=1:3, FOO=c('A_B','A_B_

[R] Cumulative split of value in data frame column

2020-06-05 Thread Ravi Jeyaraman
Assuming, I have a data frame like this .. df <- data.frame(ID=1:3, FOO=c('A_B','A_B_C','A_B_C_D_E')) I want to do a 'cumulative split' of the values in column FOO based on the delimiter '_'. The end result should be like this .. ID FOO FOO_SPLIT1 FOO_SPLIT2 FOO_SPLIT