[R] Cumulative split of value in data frame column
Ravi Jeyaraman
r@v|76 @end|ng |rom gm@||@com
Fri Jun 5 18:32:36 CEST 2020
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_SPLIT3
FOO_SPLIT4 FOO_SPLIT5
1 A_B A A_B
2 A_B_C A A_B
A_B_C
3 A_B_C_D_E A A_B A_B_C
A_B_C_D A_B_C_D_E
Any efficient, optimized way to do this?
--
This email has been checked for viruses by AVG.
https://www.avg.com
[[alternative HTML version deleted]]
More information about the R-help
mailing list