I've been struggling with the following for some time now:
I want to calculate the difference in wordcounts (frequency of occurrence of features) between two dataframes. The dataframes contain two columns: feature (words) an frequency.
I want to achieve the following result with df A en df B: All features/words from df A and frequency of A minus frequency of B. However when the feature in A does not appear in B I want the frequency of just A back.
I've tried with a two sapply functions: 1 to obtain a names vector the names: feature and frequency of A, and 1 to obtain the the frequency of the same feature in B if the feature exist otherwise 0. These two vectors where then combined to obtain the desired dataframe. The solution works, but is really slow.
Doe any of you know a faster way of obtaining such results?