lastdose | R Documentation |
This function calculates the last dose amount (LDOS
), the time after
last dose (TAD
), time after first dose (TAFD
), and observation
occasion (OCC
). Use lastdose()
to add (or potentially replace) columns to the input data frame;
lastdose_list()
and lastdose_df()
returns calculated information
as either list
or data.frame
format without modifying the input data.
lastdose(
data,
...,
include_ldos = TRUE,
include_tafd = getOption("lastdose.include_tafd", FALSE),
include_occ = getOption("lastdose.include_occ", TRUE)
)
lastdose_list(
data,
time_col = find_time_col(data),
time_units = getOption("lastdose.time_units", NULL),
id_col = find_id_col(data),
fill = -99,
back_calc = TRUE,
addl_ties = c("obs_first", "dose_first"),
comments = find_comments(data),
include_occ = getOption("lastdose.include_occ", TRUE)
)
lastdose_df(data, ...)
data |
data set as data frame; see |
... |
arguments passed to |
include_ldos |
|
include_tafd |
|
include_occ |
|
time_col |
character name for the |
time_units |
for calculating time when the time column inherits
|
id_col |
character name for the subject |
fill |
the value for |
back_calc |
if |
addl_ties |
what to do when doses scheduled through |
comments |
a logical vector with length equal to the number of rows
in |
When calling lastdose()
to modify the data frame, two columns will be
added (by default): TAD
indicating the time after the most-recent dose,
and LDOS
indicating the amount of the most recent dose. TAFD
indicating
the time after the first dose record (EVID
1 or 4) can be added via the
include_tafd
argument and users can opt out from adding LDOS
with the
include_ldos
argument.
When calling lastdose_list()
or lastdose_df()
, the respective items are
accessible with tad
, tafd
, and ldos
(note the lower case form here to
distinguish from the columns that might be added to the data frame).
Time after first dose (TAFD): note that time after first dose (TAFD
)
is the time after the first dosing record (EVID
1 or 4) in the data frame
that you pass in. If you don't have a dosing record for the first dose to
anchor this calculation, you should opt out.
Occasion (OCC): observation occasions (OCC
) occur when there is an
observation record (with EVID=0
) following a dose record (EVID 1 or 4
);
OCC
starts at 0
and increments with each dose that is followed by at
least one observation record. The OCC
calculation ignores all commented
records (doses or observations).
Handling of commented records: Dosing records that have been "commented"
(as indicated with the comments
argument) will never be considered as
actual doses when determining TAD
, TAFD
, and LDOS
. But commented
records (doses and non-doses) will be assigned TAD
, TAFD
, and LDOS
according to the last non-commented dosing record.
Additional notes:
All functions require an input data set as a data frame
The data set should be formatted according to NMTRAN
type
conventions
Required columns
A subject ID column (either ID
or user-specified)
A record time column (either TIME
or user-specified)
AMT
or amt
: dose amount for dosing records
EVID
or evid
: event ID; records with EVID
or 1 or 4
are considered dosing records
Optional columns
ADDL
or addl
: additional doses to administer
II
or ii
: dosing interval
An error is generated if required columns are not found; no error or warning if optional columns are not found
All required and optional columns are required to be numeric
Missing values are not allowed in: ID
, EVID
, ADDL
, II
When missing values are found in TIME
, both TAD
and LDOS
are set to
missing
An error is generated for missing AMT
in dosing records (evid 1 or 4)
No error is generated for missing AMT
in non-dosing records
An example illustrating the addl_ties
argument: when there is Q24h
dosing and both an an additional dose and an observation happen at 24 hours,
obs_first
will set the observation TAD
to 24 and dose_first
will set
the observation TAD
to 0.
These are options that can be set to customize lastdose
behavior
for the current context. See ?options
for how to set an option.
lastdose.time_units
: sets the default time unit that is used to calculate
relative times when the time column is represented as date-time data
(POSIXct
)
lastdose.id_col
: sets the default value for the id_col
argument
to last dose; this identifies the column that is to be used to distinguish
individuals; the data in this column may be numeric or character
lastdose.include_tafd
: sets default value for include_tafd
; if TRUE
then the time since the first dose record (EVID 1 or EVID 4) in the data
set will be automatically appended to the output data frame when
calling lastdose()
; tafd
is always included when calling
lastdose_df()
and lastdose_list()
file <- system.file("csv/data1.csv", package="lastdose")
require("Rcpp")
data <- read.csv(file)
a <- lastdose(data)
b <- lastdose_df(data)
c <- lastdose_list(data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.