Extract model lines from a rxui model
modelExtract( x, ..., expression = FALSE, endpoint = FALSE, lines = FALSE, envir = parent.frame() ) ## S3 method for class '`function`' modelExtract( x, ..., expression = FALSE, endpoint = FALSE, lines = FALSE, envir = parent.frame() ) ## S3 method for class 'rxUi' modelExtract( x, ..., expression = FALSE, endpoint = FALSE, lines = FALSE, envir = parent.frame() ) ## S3 method for class 'rxode2' modelExtract( x, ..., expression = FALSE, endpoint = FALSE, lines = FALSE, envir = parent.frame() ) ## S3 method for class 'rxModelVars' modelExtract( x, ..., expression = FALSE, endpoint = FALSE, lines = FALSE, envir = parent.frame() ) ## Default S3 method: modelExtract( x, ..., expression = FALSE, endpoint = FALSE, lines = FALSE, envir = parent.frame() )
x
: model to extract lines from
...
: variables to extract. When it is missing, it will extract the entire model (conditioned on the endpoint option below)
expression
: return expressions (if TRUE
) or strings (if FALSE
)
endpoint
: include endpoint. This can be:
NA
-- Missing means include both the endpoint and non-endpoint linesTRUE
-- Only include endpoint linesFALSE
-- Only include non-endpoint lineslines
: is a boolean. When TRUE
this will add the lines as an attribute to the output value ie attr(, "lines")
envir
: Environment for evaluating variables
expressions or strings of extracted lines. Note if there is a duplicated lhs expression in the line, it will return both lines
one.compartment <- function() { ini({ tka <- 0.45 # Log Ka tcl <- 1 # Log Cl tv <- 3.45 # Log V eta.ka ~ 0.6 eta.cl ~ 0.3 eta.v ~ 0.1 add.sd <- 0.7 }) model({ ka <- exp(tka + eta.ka) cl <- exp(tcl + eta.cl) v <- exp(tv + eta.v) d/dt(depot) <- -ka * depot d/dt(center) <- ka * depot - cl / v * center cp <- center / v cp ~ add(add.sd) }) } f <- one.compartment() modelExtract(f, cp) modelExtract(one.compartment, d/dt(depot)) # from variable var <- "d/dt(depot)" modelExtract(one.compartment, var) modelExtract(f, endpoint=NA, lines=TRUE, expression=TRUE)
Matthew L. Fidler
Useful links