I have a table (using R in Spotfire) where I am trying to determine the adjusted peak area based on data in the same table. So below is an example of the table
df <- data.frame(Sample_Name = c("Smpl 1", "Smpl 1", "Smpl 2", "Smpl 2"),
Peak_Area = c(100, 101, 50, 51),
Analyte = c("Asn","Asn*","Leu","Leu*"),
Int_Std = c("Asn*","","Leu*",""))
So for me to determine the adjusted peak area, I need to find the internal standard peak area for the same sample and same analyte name by matching the Int Std field with the Analyte field. So for sample 1, the calculated value would be 100 / 101.
Essentially, I want to look at each row. If it has both a "Analyte" and "Int Std" field value, I want it to find the other row that matches the same "Sample Name" and where "Analyte" = "Int Std", and divide the original row "Peak Area" value by the found row "Peak Area" value (100 / 101)