Stack a solved object for things like default ggplot2 plot
Arguments
- data
is a rxode2 object to be stacked.
- vars
Variables to include in stacked data; By default this is all the variables when vars is NULL.
When vars is
simand comes from arxode2ui simulation with multiple endpoints (ie it has aCMTin the simulation), it will rework the data as if it was stacked based the value based on the compartments in the multiple endpoint model.When the vars is
sim.endpoint1it will subset the stack to endpoint1, you can also have `c("sim.endpoint1", "sim.endpoint2") and the "stack" will subset to endpoint1 and endpoint2.When you specify the
simtype variables they have to be all prefixed withsimotherwise, the stack will not treat them differently.- doSim
boolean that determines if the "sim" variable in a
rxSolvedataset is actually "stacking" based on the endpoint (TRUE) or simply treatingsimas a variable.- doIpredSim
boolean that determines if the "ipredSim" variable in a
rxSolvedataset is actually "stacking" based on the endpoint (TRUE) or simply treatingipredSimas a variable.
Value
Stacked data with value and trt, where value is the values
and trt is the state and lhs variables.
See also
Other rxode2 plotting:
is.rxStackData(),
plot.rxSolve(),
rxTheme(),
stat_amt(),
stat_cens()
Examples
# \donttest{
mod <- function() {
ini({
tka <- log(1.1)
tcl <- log(3)
tv <- log(30)
})
model({
ka <- exp(tka)
cl <- exp(tcl)
v <- exp(tv)
d/dt(depot) <- -ka * depot
d/dt(central) <- ka * depot - cl / v * central
cp <- central / v
})
}
s <- rxSolve(mod, et(amt = 100) |> et(0:24))
#>
#>
#> ℹ parameter labels from comments are typically ignored in non-interactive mode
#> ℹ Need to run with the source intact to parse comments
#>
#>
head(rxStack(s, c("depot", "cp")))
#> time value trt
#> 1 0 100.0000000 depot
#> 2 1 33.2871497 depot
#> 3 2 11.0803318 depot
#> 4 3 3.6883208 depot
#> 5 4 1.2277337 depot
#> 6 5 0.4086766 depot
# }
