# Create a dataset from scratch
obs_rows(time = 12, DV = 0.12, cmt = 2)
# Pipe-friendly addition of observation record to a pre-existing dataset
library(magrittr)
obs_rows(time = 12, DV = 0.12, cmt = 2) %>%
obs_rows(time = c(24, 36, 48), DV = c(0.34, 0.56, 0.78), mdv = c(0, 1, 0), cmt = 2)
# Inform times using the `.datehour` argument:
obs_rows(.datehour = "2020-01-01 11:11", DV = 0.12, cmt = 1) %>%
obs_rows(.datehour = "2020-01-02 22:22", DV = 0.34, cmt = 1) %>%
obs_rows(time = 48, DV = 0.56, cmt = 1)
# Start from a 'mrgsolve' model
library(mrgsolve)
house() %>%
obs_rows(time = 12, DV = 0.12, cmt = 2) %>%
obs_rows(time = c(24, 36, 48), DV = c(0.34, 0.56, 0.78), mdv = c(0, 1, 0), cmt = 2) %>%
mrgsim()
# Default observation compartments
# Set default observation compartments in the code with `[OBS]`
model <- mcode("model", "
$CMT @annotated
DEPOT : Depot
CENTR : Central [OBS]
", compile = FALSE)
obs_cmt(model)
# Thus, no need to manually specify `cmt = 2` anymore.
model %>%
obs_rows(time = 12, DV = 0.12) %>%
obs_rows(time = c(24, 36, 48), DV = c(0.34, 0.56, 0.78), mdv = c(0, 1, 0)) %>%
get_data()
# Automatic lines duplication if parent + metabolite defined in the model
model <- mcode("model", "
$CMT @annotated
DEPOT : Depot
CENTR : Central [OBS]
PERIPH : Periph
METABO : Metabo [OBS]
", compile = FALSE)
obs_cmt(model)
model %>%
obs_rows(time = 12, DV = 0.12, DVmet = 120) %>%
obs_rows(
time = c(24, 36, 48), DV = c(0.34, 0.56, 0.78),
mdv = c(0, 1, 0), DVmet = c(340, 560, 780)
) %>%
get_data()
Run the code above in your browser using DataLab