Skip to content

Commit

Permalink
extra vignettes
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebaron committed Mar 23, 2021
1 parent cd08513 commit dfa1366
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 15 deletions.
7 changes: 3 additions & 4 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ docs
^\.drone\.jsonnet$
^doc$
^Meta$
vignettes/mevent\.Rmd
vignettes/mevent-0\.cpp
vignettes/mevent-1\.cpp
vignettes/extra
vignettes/build
vignettes/mrgsolve_builds
vignettes/mrgsolve-builds
vignettes/extra/mrgsolve-builds/

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ Rchecks
inst/maintenance/unit/tests.md
doc
Meta
inst/maintenance/unit/mrgsolve-so*
vignettes/mrgsolve-builds
vignettes/extra/mrgsolve-builds/
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ package:
make house
make doc
make build-vignettes
make vignettes2
make install

check:
make house
Expand All @@ -35,10 +37,14 @@ check:
cran:
make house
make doc
make vignettes2
make build-vignettes
export _MRGSOLVE_SKIP_MODLIB_BUILD_=false
R CMD CHECK --as-cran ${TARBALL}

vignettes2:
Rscript vignettes/extra/make.R

drone:
make house
R CMD build --md5 $(PKGDIR)
Expand Down
14 changes: 7 additions & 7 deletions vignettes/events.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Let's illustrate event objects with a one-compartment, PK model. We read this
model from the `mrgsolve` internal model library.

```{r,message=FALSE}
mod <- modlib("pk1cmt", end = 216, delta = 0.1)
mod <- house(end = 216, delta = 0.1)
```

# Events
Expand All @@ -61,7 +61,7 @@ We can implement this series of doses by passing `e` in as the `events` argument
to `mrgsim`

```{r}
mod %>% mrgsim(events = e) %>% plot(EV1 + CP ~ time)
mod %>% mrgsim(events = e) %>% plot(GUT + CP ~ time)
```


Expand Down Expand Up @@ -105,10 +105,10 @@ We can combine `e1` and `e3` with a collection operator
c(e1, e4)
```

`mrgsolve` also defines a `%then$` operator that lets you execute one event and
`%then%` a second event
`mrgsolve` also defines a `seq()` method that lets you execute one event and
then a second event
```{r}
e3 %then% e2
seq(e3, e2)
```

Notice that `e3` has both `ii` and `addl` defined. This is required for
Expand Down Expand Up @@ -138,10 +138,10 @@ data
```

To simulate from this data set, we use the `data_set` function. First, let's
load a population PK model
add an OMEGA matrix to this model:

```{r,message=FALSE}
mod <- modlib("popex")
mod <- omat(mod, as_dmat(c(0.1, 0.1, 0.1, 0.1)))
```
```{r}
mod %>% data_set(data) %>% mrgsim(end=336) %>% plot("GUT, DV")
Expand Down
2 changes: 2 additions & 0 deletions vignettes/extra/global.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
knitr::opts_chunk$set(message = FALSE, warning = FALSE, comment='.')
options(mrgsolve.soloc = "mrgsolve-builds")
6 changes: 6 additions & 0 deletions vignettes/extra/make.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
message("making secondary vignettes")
stopifnot(`rmarkdown is required` = require(rmarkdown))
render("vignettes/extra/time-after-dose.Rmd", output_dir = "inst/doc", quiet = TRUE)
render("vignettes/extra/modeled-event-time.Rmd", output_dir = "inst/doc", quiet = TRUE)
res <- file.remove(list.files("inst/doc", pattern = "\\.md*", full.names=TRUE))
res <- unlink("inst/doc/mtime_files", recursive = TRUE)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions vignettes/mrgsolve.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ vignette: >
---

```{r setup, echo = FALSE, message = FALSE, warning = FALSE, code = readLines("global.R")}
mod <- mread_cache("pk1", modlib())
mod <- mread_cache("pk2", modlib())
set.seed(20202)
```

Expand Down
4 changes: 2 additions & 2 deletions vignettes/steady-state.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Let's load a PK model
library(dplyr)
library(mrgsolve)
mod <- modlib("pk2")
mod <- house(end = 24, delta = 1)
```

And let's imagine a 100 mg QD dosing regimen
Expand All @@ -75,7 +75,7 @@ Let's just look at trough concentrations and see how the trough develops over
the dosing period

```{r}
mod <- update(mod, delta = 24, end = 24*20, outvars = "CENT, PERIPH")
mod <- update(mod, delta = 24, end = 24*20, outvars = "CENT, RESP")
```

And simulate that out
Expand Down

0 comments on commit dfa1366

Please sign in to comment.