I have a dataframe that is constituted by 5 factor columns. One of these columns (D)
contains 200 values (on each row) separated by a comma delimiter ','
. What I am trying to accomplish is to split this column (D)
into 200 columns in the same dataframe if possible.
data= data.frame(A = c('12223','168723','885441','99855'),
B=c('855547','98557','699854','345871'),
C=c('US', 'US', 'UK', 'IT'),
D=c('0.54,0.589,0.55,0.69,0.88,0.98'
,'0.36,0.38,0.66,0.84,0.22,0.33'
,'0.67,0.89,0.94,0.85,0.78,0.98'
,'0.14,0.12,0.13,0.11,0.17,0.19'),
E=c('1','0','1','1'))
I've tried to use the separate function from tidyr
but I get an error:
Error in Math.factor(var) : ‘abs’ not meaningful for factors
data %>% separate(data$D, into = paste("V", 1:6, sep = "_"), sep=',')