I would like to match the last occurrence of "," in a string to be able to separate
a column properly.
Sample data
tibble(
name = c("John", "James"),
company_num = c("Apple, Inc, 1000",
"Microsoft, 1200")
)
The desired output:
# A tibble: 2 x 3
name company num
<chr> <chr> <dbl>
1 John Apple, Inc 1000
2 James Microsoft 1200
What I have tried
df %>%
separate(col = company_num,
into = c("company", "num"),
sep = ", ")