I would like to split columns into two and extract and keep the numbers alone in one column.
df <- data.frame(V1 = c("[1] Strongly disagree", "[2] Somewhat disagree", "[3] Neither", "[4] Somewhat agree", "[5] Strongly agree"))
V1
[1] Strongly disagree
[2] Somewhat disagree
[3] Neither
[4] Somewhat agree
[5] Strongly agree
I tried using the separate function from tidyr :
tidyr::separate(df, V1, into = c("Value", "Label"), sep = "] ")
Value Label
[1 Strongly disagree
[2 Somewhat disagree
[3 Neither
[4 Somewhat agree
[5 Strongly agree
I might be able to remove the [ with another function, but I was wondering if I can fix this in one step and wonder if there is another function that does the job.
I am trying to get this in the end
Label Value
Strongly disagree 1
Somewhat disagree 2
Neither 3
Somewhat agree 4
Strongly agree 5