I'm trying to split a text variable that goes like this:
text = "name name name (1235-23-532)"
to something like this:
name = "name name name"
num = "1235-23-532"
I'm trying this code:
df_split <- df %>%
separate(owners,
into = c("name", "num"),
sep = "(?<=[A-Za-z])(?=\\()"
)
However, it results in the number counterpart being NA. I'm confused how it doesn't detect parenthesis (I tried both ( and \( and it doesn't work either way). Is there a good solution for this?
Also: there are some rows that has two parentheses pairs like: "name name name (name) (number)" - any good way to extract just the numbers?
Thank you very much.