blk.tad | R Documentation |
These functions compute the time after dose (TAD) for a PK data set in block-format
.
blk.tad(time, id, dose.ind, na.action = c("neg.time", "fill"), fill = NA, diff.op = difftime.default)
blk.tad2(time, id, dose.t, id2, na.action = c("neg.time", "fill"), fill = NA, diff.op = difftime.default)
time |
A vector of event times in |
id,id2 |
A valid |
dose.ind |
A logical vector in |
dose.t |
A vector of dose times in |
na.action |
How to handle events prior to the first dose. See details. |
fill |
A value to use when no other value is appropriate. |
diff.op |
A function that subtracts one time from another. |
These functions compute the TAD, the difference between the time of a PK observation and the time of the dosing event that most nearly precedes it.
There are two variants. In the first variant, all event times are in a
single vector and an indicator is used to distiguish between dose events and
observation events. In the second variant, dose times and observation times
are in separate vectors, each with an associated block-format
ID vector. In the case where a dose time and observation time match exactly,
in the first variant events occur in the order specified, while in the second
variant it is always assumed that the observation comes first (i.e.
observations precede doses at the same time).
There are two ways of handling observations that occurs before the first
dose. If na.action == "neg.time"
(the default), then the TAD values for
these observations are negative, and their magnitudes are the time
until the first dose. If na.action == "fill"
then the value of
fill
is used to ‘fill in’ the TAD for all such observations.
A numeric vector of TAD values in block-format
with respect to id
.
Benjamin Rich <mail@benjaminrich.net>
tapply
difftime
require(nlme)
data(Phenobarb)
dat <- Phenobarb[1:56,] # First 4 subjects
attach(dat)
cbind(dat, TAD=blk.tad(time, asID(Subject), !is.na(dose)))
detach(dat)
id <- gl(4, 6)
id2 <- gl(4, 2)
time <- rep(c(0, 1, 6, 12, 18, 24), 4)
dose.t <- rep(c(0, 12), 4)
data.frame(id=id, time=time, tad=blk.tad2(time, id, dose.t, id2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.