I'd like to break this column into 2, using the first bracket as the separater. I used word(x,2, sep = "(") but I got an error. I understand that R doesn't like brackets as sep. I want to use "(" as a sep because the data is not consistently recorded, on some rows, we have a space between the country and the state, on some other rows we don't.
How do I get around this? Thank you.
x <- c("United States (Alabama) ", "United States (California) ",
"United States (California) ", "United States (California) ",
"United States (California) ", "United States (Colorado) ",
"United States (Colorado) ", "United States (Colorado) ",
"United States(Connecticut) ", "United States(Connecticut) "
)
word(x,2,sep = "(").
Error in stri_locate_all_regex(string, pattern, omit_no_match = TRUE, : Incorrectly nested parentheses in regexp pattern. (U_REGEX_MISMATCHED_PAREN, context=
()