Struggling with string handling in R...
I've got a column of strings in an R data frame. Each one contains the "="
character once and only once. I'd like to know the position of the "="
character in each element of the column, as a step to splitting the column into two separate columns (one for the bit before the "="
and one for the bit after the "="
). Can anyone help please? I'm sure it's simple but I'm struggling to find the answer.
For example, if I have:
x <- data.frame(string = c("aa=1", "aa=2", "aa=3", "b=1", "b=2", "abc=5"))
I'd like a bit of code to return
(3, 3, 3, 2, 2, 4)
Thank you.