I'm quite a new R user and it would be awesome if someone could help me to figure this out!
I have data looking like this:
eDNA.data
Sample Extraction_batch Species 1 Species 2 Specie3 Species 4
CH15_25 CH_1 0 39 10 0
CH15_89 CH_2 11 0 55 0
CH15_56 CH_1 0 0 0 13
CH15_16 CH_1 27 12 0 7
CH15_21 CH_2 0 0 2 0
CH15_negA CH_1 0 1 0 0
CH15_negB CH_2 0 0 2 1
IQ15_10 IQ_1 8 67 43 0
IQ15_64 IQ_1 17 0 24 6
IQ15_17 IQ_2 5 0 0 0
IQ15_87 IQ_1 0 11 7 0
IQ15_negA IQ_1 1 0 0 0
IQ15_negB IQ_2 0 0 1 1
I have 218 species in total and a lot more samples (148 in total) which are DNA extractions. The Extraction_batch
column correspond to which extraction the samples belong (because I could only do 24 at the time) and for each extraction batch there is one negative control corresponding. Negative control are blank samples to see if contamination occured during the extraction.
I would like to subtract the row of the negatives controls (ex. IQ15_negA) to all the rows corresponding to the same value in the column Extraction_batch
. So I could obtain a new dataframe contamination free.
How can I do this in R?