My first dataset (MSdata1) looks like this
m.z Intensity Relative Delta..ppm. RDB.equiv. Composition
301.14093 7646 100.00 -0.34 5.5 C16 H22 O4 Na
149.02331 4083458.5 23.60 -0.08 6.5 C8 H5 O3
279.15908 33256 18.64 -0.03 5.5 C16 H23 O4
My second dataset (MSdata2) looks like this
m.z Intensity Relative Delta..ppm. RDB.equiv. Composition
331.11233 4324 94.00 -0.33 6.5 C17 H26 O5 Na
149.02331 4083458.5 23.60 -0.08 6.5 C8 H5 O3
279.15908 42315 18.64 -0.03 5.5 C16 H23 O4
I am trying to subtract the the two datasets in the $Intensity column, based on the "ID" of each row, which is the $Composition column. (MSdata2$Intensity minus MSdata1$Intensity)
My attempt is
!(data33$Composition %in% data3$Composition)
but this and its variations either give me TRUE/FALSE output or it unfortunately subtracts everything, which is not my end goal. I have found similar questions, but they either do not deal with strings -- or their two datasets are of very similar size and content. My two datasets will have a lot of different information with similarities throughout - it's those similarities that I want to subtract to understand their differences better.
Which is,
m.z Intensity Relative Delta..ppm. RDB.equiv. Composition
301.14093 -7646 100.00 -0.34 5.5 C16 H22 O4 Na
149.02331 0 23.60 -0.08 6.5 C8 H5 O3
279.15908 9059 18.64 -0.03 5.5 C16 H23 O4
Thank you for any help you have to offer! :(
EDIT - I have changed my output so that $Composition strings not found in the first dataset, results in a negative output ( example, 0-100 = -100)