| time_calc | R Documentation |
This function calculates the most important time variables based on multiple variables in a data frame.
time_calc(
data,
datetime,
evid = NULL,
addl = NULL,
ii = NULL,
amt = "AMT",
id = "ID",
dig = 2
)
data |
data frame to perform the calculations on |
datetime |
character identifying the date/time variable (POSIXct) within the data frame |
evid |
character identifying the event ID (EVID) within the data frame |
addl |
character identifying the additional dose levels (ADDL) within the data frame |
ii |
character identifying the interdose interval (II) within the data frame |
amt |
character identifying the amount variable (only needed if |
id |
character identifying the ID or subject variable |
dig |
numeric indicating with how many digits the resulting times should be available |
The function calculates the TIME, TALD (time after last dose) and TAFD (time after first dose). The different time variables are calculated in hours, where a POSIXct for the datetime variable is expected. The function takes into account ADDL and II records when provided, to correctly identify the TALD. One must be cautious however when having ADDL/II and a complex dosing schedule (e.g. alternating dose schedules, more than 1 dose per day, multiple compounds administration). In general it is good practice to double check the output for multiple subjects in case of complex designs including ADDL/II.
a data frame with the calculated times
Richard Hooijmaijers
dfrm <- data.frame(ID=rep(1,5), dt=Sys.time() + c(0,8e+5,1e+6,2e+6,3e+6),
AMT=c(NA,10,NA,0,NA), II=rep(24,5),EVID=c(0,1,0,1,0))
time_calc(dfrm,"dt","EVID")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.