I have this data in R:
string_1 = c("newyork 123", "california 123", "washington 123")
string_2 = c("123 red", "123 blue", "123 green")
my_data = data.frame(string_1, string_2)
I want to "subtract" string_2 from string_1. The result would look something like this:
"newyork", "california", "washington"
I tried to do this:
library(tidyverse)
# did not work as planned
> str_remove(string_1, "string_2")
[1] "newyork 123" "california 123" "washington 123"
But this is not performing a "full" subtraction.
- Does anyone know how to do this?
- Should I try to do this with an ANTI JOIN in SQL?
Thank you!