Jason Ching Yuk Jason Ching Yuk - 6 months ago 25
R Question

Splitting Columns that contain decimal point values in R

I facing difficulties splitting columns in R. For instance

and over 100x records

I did

tidyr::separate(df, Col1.Col2.Col3,
c("Col1", "Col2", "Col3" ))

And i get

Col1 Col2 Col3
12 3 10
11 3 11
85 89 3
and over 100x records

I realised that the decimal value is moved to the next column and the values of Col3 were left out. How can i fix this or is there a better way of splitting the columns?


tidyr::separate has a sep argument that controls where the splits occur. Use sep = ",".