# 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()
Run the code above in your browser using DataLab