Skip to content
Prev 377518 / 398503 Next

detecting measurement of specific id in column in R

Dear all,

if the attachment didn?t arrive, maybe it works now.
I would like to substract the "IN" values (= the air which goes into the
chambers) for "d13C", "ppm_CO2" and "ppm_13CO2"
from the "d13C", "ppm_CO2" and "ppm_13CO2" for every single chamber.
I need to substract the "IN" values which were measured *before* the
chamber.

So the calculation would look like df$d13C [chambers] - df$d13C [IN]
                                                       df$ppm_CO2
[chambers] - df$ppm_13CO2 [IN]
                                                       df$ppm_13CO2
[chambers] - df$ ppm_13CO2 [IN]
--> for chamber 101-111 this should be the first "IN" (No 1)
--> for chamber 1-11 this should be the second "IN" (No 12)
...and so on

I tried sth. like which(abs(date-x) == min(abs(date-x), but it just gives
me the closest "IN" in time and not the "IN" before.

I would appreciate any help!
Thank you so much, Vicci

Am Do., 22. Nov. 2018 um 17:53 Uhr schrieb Rui Barradas <
ruipbarradas at sapo.pt>:
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Example.txt
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20181122/926dbcef/attachment.txt>