A sample of my data is as follows:
df1 <- read.table(text = "var Time
12O 12
13O 11
22B 45
33Z 22
21L 2
11M 13", header = TRUE)
I want to separate values in column "Var" to get the following data:
df2 <- read.table(text = " Group1 Group2 Group3
1 2 O
1 3 O
2 2 B
3 3 Z
2 1 L
1 1 M", header = TRUE)
I tried the following codes:
df2 <- df1 %>% separate(var, into = c('Group1', 'Group2','Group3'), sep = 1)
I get an error. I have searched to find the error out, but I have failed.