addTAPD {NMdata} | R Documentation |
Add time since previous dose to data, time of previous dose, most recent dose amount, cumulative number of doses, and cumulative dose amount.
Description
For now, doses have to be in data as EVID=1 and/or EVID=4
records. They can be in the format of one row per dose or repeated
dosing notation using ADDL
and II
.
Usage
addTAPD(
data,
col.time = "TIME",
col.evid = "EVID",
col.amt = "AMT",
col.tpdos = "TPDOS",
col.tapd = "TAPD",
col.pdosamt = "PDOSAMT",
col.doscuma = "DOSCUMA",
col.doscumn = "DOSCUMN",
prefix.cols,
suffix.cols,
subset.dos,
subset.is.complete,
order.evid = c(3, 0, 2, 4, 1),
by = "ID",
SDOS = 1,
as.fun,
col.ndoses
)
Arguments
data |
The data set to add the variables to. |
col.time |
Name of time column (created by
|
col.evid |
The name of the event ID column. This must exist in data. Default is EVID. |
col.amt |
col.evid The name of the dose amount column. This must exist in data. Default is AMT. |
col.tpdos |
Name of the time of previous dose column (created
by |
col.tapd |
Name of the time of previous dose column (created
by |
col.pdosamt |
The name of the column to be created holding the previous dose amount. Set to NULL to not create this column. |
col.doscuma |
The name of the column to be created holding the cumulative dose amount. Set to NULL to not create this column. |
col.doscumn |
The name of the column (created by addTAPD) that holds the cumulative number of doses administered to the subject. Set to NULL to not create this column. |
prefix.cols |
String to be prepended to all generated column names, that is each of col.tpdos, col.tapd, col.ndoses, col.pdosamt, col.doscuma that are not NULL. |
suffix.cols |
String to be appended to all generated column names, that is each of col.tpdos, col.tapd, col.ndoses, col.pdosamt, col.doscuma that are not NULL. |
subset.dos |
A string that will be evaluated as a custom expression to identify relevant events. See subset.is.complete as well. |
subset.is.complete |
Only used in combination with non-missing subset.dos. By default, subset.dos is used in addition to the impact of col.evid (must be 1 or 4) and col.amt (greater than zero). If subset.is.complete=TRUE, subset.dos is used alone, and col.evid and col.amt are completely ignored. This is typically useful if the events are not doses but other events that are not expressed as a typical dose combination of EVID and AMT columns. |
order.evid |
Order of events. This will only matter if there are simultaneous events of different event types within subjects. Typically if using nominal time, it may be important to specify whether samples at dosing times are pre-dose samples. The default is c(3,0,4,1,2) - i.e. samples and simulations are pre-dose. See details. |
by |
Columns to do calculations within. Default is ID. |
SDOS |
Scaling value for columns related to dose amount, relative to AMT values. col.pdosamt and col.doscuma are affected and will be derived as AMT/SDOSE. |
as.fun |
The default is to return data as a data.frame. Pass a function (say tibble::as_tibble) in as.fun to convert to something else. If data.tables are wanted, use as.fun="data.table". The default can be configured using NMdataConf. |
col.ndoses |
Deprecated. Use col.doscumn instead. |
Details
addTAPD does not require the data to be ordered, and it will not order it. This means you can run addTAPD before ordering data (which may be one of the final steps) in data set preparation. The argument called order.evid is important because of this. If a dosing event and a sample occur at the same time, when which dose was the previous for that sample? Default is to assume the sample is a pre-dose sample, and hence output will be calculated in relation to the dose before. If no dose event is found before, NA's will be assigned.
Value
A data.frame with additional columns
See Also
Other DataCreate:
NMorderColumns()
,
NMstamp()
,
NMwriteData()
,
findCovs()
,
findVars()
,
flagsAssign()
,
flagsCount()
,
mergeCheck()
,
tmpcol()