TTT flawed in case of a lagtime… [🇷 for BE/BA]
Hi Helmut,
Not thoroughly tested, but if I get your drift, then here's something to consider:
Not thoroughly tested though
❝ Does anybody have a clever idea how I can find the lagtime in R without a loop? Essentially I would search backwards from tmax until I find the first NA.
Not thoroughly tested, but if I get your drift, then here's something to consider:
time=c(1,2,3,4,5,6,7,8,9,10)
conc=c(NA,NA,NA,5,19,56, 53,46,40, NA)
data=data.frame(time, conc)
d1=subset(data, !(is.na(conc))) ##d1 now holds everything not NA
Tmax=subset(d1, conc==max(d1[,2]))[1,1] ##records Tmax
d4=subset(data, (is.na(conc)) &(time<Tmax) ) ##takes all NA's observed until Tmax
Tlag=(subset(data, (is.na(conc))&&(time<Tmax)))[nrow(d4),1] ##Time of last observed NA before Tmax
Not thoroughly tested though

—
Pass or fail!
ElMaestro
Pass or fail!
ElMaestro
Complete thread:
- ‘Automatic’ selection of time points for λz Helmut 2013-07-22 19:14
- New code Helmut 2013-07-23 02:06
- TTT flawed in case of a lagtime… Helmut 2013-07-23 19:59
- TTT flawed in case of a lagtime… martin 2013-07-23 20:22
- TTT flawed in case of a lagtime…ElMaestro 2013-07-23 22:35
- minimalistic R Helmut 2013-07-24 01:04
- Wow, very efficicient ElMaestro 2013-07-24 10:49
- R’s semantic riddles Helmut 2013-07-24 14:10
- Wow, very efficicient ElMaestro 2013-07-24 10:49
- minimalistic R Helmut 2013-07-24 01:04
- TTT flawed in case of a lagtime… Helmut 2013-07-23 19:59
- New code Helmut 2013-07-23 02:06