I have a data.frame which contains a column with values like this:
[2] wererea 187w 50HH (1)
[3] werewefrea 145y 50HH (4)
[5] weredssda 100NH (2)
I would like to separate this column into two columns and the separation should be done at the first space. How I do it now is with the help of the ] like this:
DF <- separate(DF , "X", into = c("X","Y"), sep = "\\] ", remove = TRUE)
DF$X<- gsub("\\[", "", DF$X)
The way to select the last space goes like this:
DF <- separate(DF, "X", into = c("X","Y"), sep = " (?=[^ ]*$)", remove = TRUE)
I found this RegEx:
^([^ ]*)
But this will select the first space AND everthing before it. But how do you select only the first space?