0

I have a data frame with one column, data. A sample:

data
13.43,100.34
12.344,98.3242

I want to separate the numbers either side of the comma into two columns (and delete the comma), 'A' and 'B'. I.e. the objective is:

A       B
13.43   100.34 
12.344  98.3242

I've tried the following code:

library(tidyverse)

new_df <- old_df %>% separate(data, into = c('A', 'B'), sep = '^.+,')

but printing the new_df shows a blank A column:

A       B
        100.34 
        98.3242

Does anybody know why/how to fix?

0 Answers0