Skip to contents

rxode2 accepts doses and observation times in several ways. Pick the row that matches what you are trying to do:

You want to… Use Read
Solve with an existing NONMEM-style (or deSolve-style) dataset a data frame Dataset columns
See how a bolus, infusion, steady state or reset behaves et() or a data frame Dosing event types
Build a regimen and sampling times in R et() Building event tables with et()
Chain, repeat or stack regimens (e.g. bid then qd, cycles) seq(), rep(), rbind() on et() Combining event tables
Dose based on the model state (e.g. adaptive or TDM dosing) bolus(), infuse(), … in model() Dosing from inside the model
Dose by body weight covariate-scaled dose Weight-based dosing
Split one dose across two absorption routes splitBolus() Dual absorption with splitBolus()
Read or write old RxODE evid codes (100s, 10000s) classic evid Classic evid codes

A quick example of the most common case – a twice-daily dose with observation times – built with et():

## rxode2 5.1.8.9000 using 2 threads (see ?getRxThreads)
##   no cache: create with `rxCreateCache()`
ev <- et(amt = 100, ii = 12, until = 72) |>
  et(seq(0, 72, by = 1))
head(ev)
## ── EventTable with 6 records ──
## 1 dosing records (see x$get.dosing(); add with add.dosing or et)
## 5 observation times (see x$get.sampling(); add with add.sampling or et)
## multiple doses in `addl` columns, expand with x$expand(); or etExpand(x)
## ── First part of x: ──
## # A tibble: 6 × 5
##    time   amt    ii  addl evid         
##   <dbl> <dbl> <dbl> <int> <evid>       
## 1     0    NA    NA    NA 0:Observation
## 2     0   100    12     6 1:Dose (Add) 
## 3     1    NA    NA    NA 0:Observation
## 4     2    NA    NA    NA 0:Observation
## 5     3    NA    NA    NA 0:Observation
## 6     4    NA    NA    NA 0:Observation

The same table as a NONMEM-style data frame is what rxSolve() sees:

##   time amt ii addl evid
## 1    0  NA NA   NA    0
## 2    0 100 12    6    1
## 3    1  NA NA   NA    0
## 4    2  NA NA   NA    0
## 5    3  NA NA   NA    0
## 6    4  NA NA   NA    0