I'm essentially trying to "background subtract" the data I have. So here I have two sample data sets. Please note that the 'm/z' column cannot be used for the subtraction since the associated numbers will not always be exactly the same. With multiple strings, I have no idea how this can be done and I'm not even sure if I'm asking the right questions since I'm new to this.
Solution = df_sub < - anti_join(df, dfbkg, by = 'Composition') (This works with strings too!)
df <- read.csv(file)
m/z             Composition
241             C15 H22 O Na                
265             C15 H15 N5 
301             C16 H22 O4 Na 
335             C19 H20 O4 Na           
441             C26 H42 O4 Na 
and my "background"
df_bkg <- read.csv(file_2)
m/z             Composition
274             C18 H19 O Na 
301             C16 H22 O4 Na 
317             C16 H22 O5 Na       
441             C26 H42 O4 Na 
241             C15 H22 O Na 
The background contains three similar strings in the Composition column compared to my data. I would like the new "subtracted dataset" to look like this..
df_sub <- (df - df_bkg)
m/z             Composition
274             C18 H19 O Na  
317             C16 H22 O5 Na       
Thank you for any help you can offer.
 
    