I have a character variable that I would like to split into 2 variables based on a \"-\" delimiter, however, I would only like to split based on the last delimiter as there
Using unglue you would do :
# install.packages("unglue")
library(unglue)
df <- data.frame(input = c("foo - bar","hey-now-man","say-now-girl","fine-now"))
unglue_unnest(df, input, "{output1}{=\\s*-\\s*}{output2=[^-]+}", remove = FALSE)
#> input output1 output2
#> 1 foo - bar foo bar
#> 2 hey-now-man hey-now man
#> 3 say-now-girl say-now girl
#> 4 fine-now fine now
Created on 2019-11-06 by the reprex package (v0.3.0)