Skip to content

Commit

Permalink
include plot
Browse files Browse the repository at this point in the history
  • Loading branch information
philipdelff committed Oct 30, 2024
1 parent 193edfb commit 3f06587
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,18 @@ Since `NMscanData` is so general and will figure out where to find
input and output data on its own, let's use the `NMscanMultiple`
wrapper to read multiple models and compare their predictions.

```{r}
```{r,NMscanMultiple-plot}
res <- NMscanMultiple(dir=system.file("examples/nonmem", package="NMdata"),
file.pattern="xgxr.*\\.lst",as.fun="data.table",quiet=TRUE)
file.pattern="xgxr.*\\.lst",as.fun="data.table",quiet=TRUE)
gmean <- function(x)exp(mean(log(x)))
res.mean <- res[,.(gmeanPRED=gmean(PRED)),by=.(model,NOMTIME)]
obs.all <- unique(res[,.(ID,NOMTIME,TIME,DV)])
ggplot(res.mean,aes(NOMTIME,gmeanPRED,colour=model))+geom_line()+
geom_point(aes(TIME,DV),data=obs.all,inherit.aes=FALSE)+
geom_point(aes(TIME,DV),data=obs.all[!is.na(DV)],inherit.aes=FALSE)+
scale_y_log10()+
labs(x="Time",y="Concentration",subtitle="Comparison of population predictions")
labs(x="Time",y="Concentration",subtitle="Comparison of population predictions")+
theme_bw()+
theme(legend.position="bottom")
```


Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,22 +158,24 @@ read multiple models and compare their predictions.

``` r
res <- NMscanMultiple(dir=system.file("examples/nonmem", package="NMdata"),
file.pattern="xgxr.*\\.lst",as.fun="data.table",quiet=TRUE)
file.pattern="xgxr.*\\.lst",as.fun="data.table",quiet=TRUE)
#> $DATA section extracted
#> Based on that, data files related to this file were expected:
gmean <- function(x)exp(mean(log(x)))
res.mean <- res[,.(gmeanPRED=gmean(PRED)),by=.(model,NOMTIME)]
obs.all <- unique(res[,.(ID,NOMTIME,TIME,DV)])
ggplot(res.mean,aes(NOMTIME,gmeanPRED,colour=model))+geom_line()+
geom_point(aes(TIME,DV),data=obs.all,inherit.aes=FALSE)+
geom_point(aes(TIME,DV),data=obs.all[!is.na(DV)],inherit.aes=FALSE)+
scale_y_log10()+
labs(x="Time",y="Concentration",subtitle="Comparison of population predictions")
labs(x="Time",y="Concentration",subtitle="Comparison of population predictions")+
theme_bw()+
theme(legend.position="bottom")
#> Warning: Transformation introduced infinite values in continuous y-axis

#> Warning: Transformation introduced infinite values in continuous y-axis
```

<img src="man/figures/README-unnamed-chunk-3-1.png" width="100%" />
<img src="man/figures/README-NMscanMultiple-plot-1.png" width="100%" />

## Get the most recent version

Expand Down
Binary file added man/figures/README-NMscanMultiple-plot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3f06587

Please sign in to comment.