Skip to content
Prev 377528 / 398502 Next

detecting measurement of specific id in column in R

Hi

It could be done by ave function if you prepare chamber column to such task

library(zoo)
#make new column ch
rrdf$ch<-rrdf$chamber
#change what is not IN to NA
rrdf$ch[which(rrdf$chamber!="IN")]<-NA
#make distinct identifier for each IN chunk
rrdf$ch[which(rrdf$chamber=="IN")]<-paste("IN", 1:3, sep="")
fill NA values
rrdf$ch<-na.locf(rrdf$ch)

ave(rrdf[,4], rrdf$ch, FUN=function(x) x-x[1])

gives you values which could be added to original data e.g.

rrdf$ppm_13CO2_delta <- ave(rrdf$ ppm_13CO2, rrdf$ch, FUN=function(x) x-x[1])

Cheers
Petr
Osobn? ?daje: Informace o zpracov?n? a ochran? osobn?ch ?daj? obchodn?ch partner? PRECHEZA a.s. jsou zve?ejn?ny na: https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information about processing and protection of business partner?s personal data are available on website: https://www.precheza.cz/en/personal-data-protection-principles/
D?v?rnost: Tento e-mail a jak?koliv k n?mu p?ipojen? dokumenty jsou d?v?rn? a podl?haj? tomuto pr?vn? z?vazn?mu prohl??en? o vylou?en? odpov?dnosti: https://www.precheza.cz/01-dovetek/ | This email and any documents attached to it may be confidential and are subject to the legally binding disclaimer: https://www.precheza.cz/en/01-disclaimer/