I have a small problem that I can't seem to solve. Given two columns:
dt <- data.table(ColumnA = c("A,B,C,A,A,A", "A,B,C"), ColumnB = c("A,C,A", "C"))
I would like to "subtract" columnB from columnA, which will result in:
data.table(Result = c("B,A,A", "A,B"))
How would one achieve this fact without first transforming it into a list and then try to subtract the list? In addition, since the dataset is quite big, it cannot be done using a for loop in R.
Every item in the comma seperated string should be treated as one item and should be subtracted only once if it occurs once. Hence not all A's are gone in the first row.