I am comparing two columns and I do want to extract only characters that were added on previous column values. I only want to compare differences and extract added characters to previous value on row..Look at this table and see how expected output on diff column should look like.
dput(df)
structure(list(v1 = c("John|Alice,Mark|mercy, Austin|Silva", "Eunice|stoney, Brandon|Mary", "Apple| -Mango"),
v2 = c("John|Alice,Mark|mercy, Austin|Silva|James |Jacy", "NA ", "Apple| +Mango | Orange"),
diff = c("|James |Jacy","NA", "+ |Orange")),
class = "data.frame", row.names = c(NA, -3L))
I have tried this code but it gives me the whole values in column1 and column2 but I want it to give the newly added characters to the previous one
library(dplyr); library(stringr)
dff <- df %>% mutate(diff = str_remove(v1,v2))