Jason Ching Yuk Jason Ching Yuk - 3 months ago 8
R Question

Extracting data into new columns using R

I am new to R, I am facing difficulties extracting data into new columns. My current data frame looks like this

Column1.Column2.Column3
10,22,32
52,2,5
51,29,6


And I wish to make it like this, in table format. How can i do it?

Column1 Column2 Column3
10 22 32
52 2 5
51 29 6

Answer

We can use read.csv

read.csv(text=as.character(df[,1]), header=FALSE, col.names = scan(text=names(df),
                  what="", sep=".", quiet=TRUE))
#  Column1 Column2 Column3
#1      10      22      32
#2      52       2       5
#3      51      29       6
Comments