adm_rows {mapbayr} | R Documentation |
Add administration lines to a dataset
Description
The adm_rows()
function adds an one or several administration lines to a dataset provided as a proper data.frame or within a 'mrgsolve' model. Used in combination with obs_rows()
and add_covariates()
, it helps the creation of datasets in the proper format for simulations with 'mrgsolve' or parameter estimation with 'mapbayr', as explained in data_helpers.
Usage
adm_rows(x, ...)
## S3 method for class 'data.frame'
adm_rows(
x,
ID = NULL,
time = NULL,
evid = 1L,
cmt,
amt,
mdv = 1L,
addl = NULL,
ss = NULL,
ii = NULL,
rate = NULL,
.datehour = NULL,
...
)
## S3 method for class 'missing'
adm_rows(...)
## S3 method for class 'mrgmod'
adm_rows(x, cmt = adm_cmt(x), rate = NULL, ...)
Arguments
x |
either a data.frame or a 'mrgsolve' model object |
... |
additional columns or arguments for |
ID |
subject ID (default is 1) |
time |
event time. Default is 0 if no previous events. Mind consistency with |
evid |
event identification (default is 1 for administration, 0 for observation) |
cmt |
compartment (no default, except if |
amt |
dose amount (for administration records only) |
mdv |
missing dependent value (default is 1 for administration records) |
addl |
additional dose (optional) |
ss |
steady-state (optional, is this dose the last of an infinity of administration? Yes, 1, or no, 0) |
ii |
inter-dose interval (optional, use it with |
rate |
rate of administration (optional, set to -2 if you model zero-order infusion. See |
.datehour |
a object of class POSIXct, a number or a character vector that can be passed to |
Value
a data.frame, or a 'mrgsolve' model with a dataset in the @args$data
slot (accessible with get_data()
).
See Also
Examples
# Create a dataset from scratch
adm_rows(amt = 100, cmt = 1)
# Pipe-friendly addition of administration record to a pre-existing dataset
library(magrittr)
adm_rows(amt = 100, cmt = 1) %>%
adm_rows(time = 3, amt = 200, cmt = 1, addl = 3, ii = 1)
# Inform times using the `.datehour` argument:
adm_rows(.datehour = "2020-01-01 11:11", amt = 100, cmt = 1) %>%
adm_rows(.datehour = "2020-01-02 22:22", amt = 200, cmt = 1) %>%
adm_rows(time = 48, amt = 300, cmt = 1)
# Start from a 'mrgsolve' model
library(mrgsolve)
house() %>%
adm_rows(amt = 100, cmt = 1) %>%
adm_rows(time = 3, amt = 200, cmt = 1, addl = 3, ii = 1) %>%
mrgsim(delta = 1)
# Default administration compartments
# Set default administration compartments in the code with `[ADM]`
model <- mcode("model", "
$CMT @annotated
DEPOT : Depot [ADM]
CENTR : Central
", compile = FALSE)
adm_cmt(model)
# Thus, no need to manually specify `cmt = 1` anymore.
model %>%
adm_rows(amt = 100) %>%
adm_rows(time = 3, amt = 200, addl = 3, ii = 1) %>%
get_data()
# Automatic lines duplication if multiple depot compartments
# Automatic `rate = -2` increment if model with 0-order absorption
model <- mcode("model", "
$PARAM DUR = 1.0
$CMT @annotated
DEPOT : Depot [ADM]
CENTR : Central [ADM]
$MAIN
D_CENTR = DUR ;
", compile = FALSE)
adm_cmt(model)
model %>%
adm_rows(amt = 100) %>%
adm_rows(time = 3, amt = 200, addl = 3, ii = 1) %>%
get_data()