diff --git a/DESCRIPTION b/DESCRIPTION index b009f51a..3c543805 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: NMdata Type: Package Title: Preparation, Checking and Post-Processing Data for PK/PD Modeling -Version: 0.0.17.911 +Version: 0.1.0 Authors@R: c(person("Philip", "Delff", email = "philip@delff.dk", role = c("aut", "cre"))) Maintainer: Philip Delff Description: Efficient tools for preparation, checking and post-processing of data in PK/PD (pharmacokinetics/pharmacodynamics) modeling, with focus on use of Nonmem. Attention is paid to ensure consistency, traceability, and Nonmem compatibility of Data. Rigorously checks final Nonmem datasets. Implemented in 'data.table', but easily integrated with 'base' and 'tidyverse'. diff --git a/R/NMcheckData.R b/R/NMcheckData.R index 8c911b27..d4f124e6 100644 --- a/R/NMcheckData.R +++ b/R/NMcheckData.R @@ -180,11 +180,13 @@ ##' } ##' @return A table with findings ##' @examples +##' \dontrun{ ##' dat <- readRDS(system.file("examples/data/xgxr2.rds", package="NMdata")) ##' NMcheckData(dat) ##' dat[EVID==0,LLOQ:=3.5] ##' ## expecting LLOQ only for samples ##' NMcheckData(dat,cols.num=list(c("STUDY"),"EVID==0"=c("LLOQ"))) +##' } ##' @import data.table ##' @export diff --git a/R/NMscanData.R b/R/NMscanData.R index b6bfdb15..8c916a30 100644 --- a/R/NMscanData.R +++ b/R/NMscanData.R @@ -151,7 +151,9 @@ ##' \item{NULL}{The NULL argument to specify missing value string in input data is not respected. If delimited input data is read (as opposed to rds files), missing values are assumed to be represented by dots (.).} ##' } ##' @examples +##' \dontrun{ ##' res1 <- NMscanData(system.file("examples/nonmem/xgxr001.lst", package="NMdata")) +##' } ##' @return A data set of class 'NMdata'. ##' @family DataRead ##' @import data.table diff --git a/R/NMscanMultiple.R b/R/NMscanMultiple.R index 853835a3..0fd4f26e 100644 --- a/R/NMscanMultiple.R +++ b/R/NMscanMultiple.R @@ -18,11 +18,13 @@ ##' @param ... Additional arguments passed to NMscanData. ##' @return All results stacked, class as defined by as.fun ##' @examples +##' \dontrun{ ##' res <- NMscanMultiple(dir=system.file("examples/nonmem", package="NMdata"), ##' file.pattern="xgxr01.*\\.lst",as.fun="data.table") ##' res.mean <- res[,.(meanPRED=exp(mean(log(PRED)))),by=.(model,NOMTIME)] ##' library(ggplot2) -##' ggplot(res.mean,aes(NOMTIME,meanPRED,colour=model))+geom_line() +##' ggplot(res.mean,aes(NOMTIME,meanPRED,colour=model))+geom_line() +##' } ##' @export diff --git a/R/NMwriteData.R b/R/NMwriteData.R index 0c6a6cc8..a2cbb6d2 100644 --- a/R/NMwriteData.R +++ b/R/NMwriteData.R @@ -48,15 +48,15 @@ ##' Nonmem. ##' @param save Save defined files? Default is TRUE. If a variable is ##' used to control whether a script generates outputs (say -##' `writeOutputs=TRUE/FALSE`), if you use `save=writeOutputs` to -##' comply with this. +##' \code{writeOutputs=TRUE/FALSE)}, if you use +##' \code{save=writeOutputs} to comply with this. ##' @param args.NMgenText List of arguments to pass to NMgenText - the ##' function that generates text suggestion for INPUT and DATA ##' sections in the Nonmem control stream. You can use these ##' arguments to get a text suggestion you an use directly in -##' Nonmem - and NMwriteSection can even update multiple Nonmem -##' control streams based on the result. This will update your -##' control streams to match your new data file with just one +##' Nonmem - and \code{NMwriteSection} can even update multiple +##' Nonmem control streams based on the result. This will update +##' your control streams to match your new data file with just one ##' command. ##' @param csv.trunc.as.nm If TRUE, csv file will be truncated ##' horizontally (columns will be dropped) to match the $INPUT diff --git a/R/findCovs.R b/R/findCovs.R index 3fdbac5c..b9c7897f 100644 --- a/R/findCovs.R +++ b/R/findCovs.R @@ -39,10 +39,12 @@ ##' ## occasion level ##' findCovs(findVars(dt1,"ID"),c("ID","OCC")) ##' ## Based on a "real data example" +##' \dontrun{ ##' dat <- NMscanData(system.file("examples/nonmem/xgxr001.lst", package = "NMdata")) ##' findCovs(dat,by="ID") ##' ### Without an ID column we get non-varying columns ##' findCovs(dat) +##' } ##' @export diff --git a/R/flagsAssign.R b/R/flagsAssign.R index fbecf77c..0500c52b 100644 --- a/R/flagsAssign.R +++ b/R/flagsAssign.R @@ -48,6 +48,7 @@ ##' @import data.table ##' @family DataCreate ##' @examples +##' \dontrun{ ##' pk <- readRDS(file=system.file("examples/data/xgxr2.rds",package="NMdata")) ##' dt.flags <- data.frame( ##' flagn=10, @@ -59,6 +60,7 @@ ##' col.flagn="flagn",col.flagc="flagc") ##' unique(pk[,c("EVID","flagn","flagc","BLQ")]) ##' flagsCount(pk[EVID==0],dt.flags,col.flagn="flagn",col.flagc="flagc") +##' } ##' @export diff --git a/R/flagsCount.R b/R/flagsCount.R index 0c205186..ba6bce34 100644 --- a/R/flagsCount.R +++ b/R/flagsCount.R @@ -67,6 +67,7 @@ ##' @import data.table ##' @family DataCreate ##' @examples +##' \dontrun{ ##' pk <- readRDS(file=system.file("examples/data/xgxr2.rds",package="NMdata")) ##' dt.flags <- data.frame( ##' flagn=10, @@ -78,6 +79,7 @@ ##' col.flagn="flagn",col.flagc="flagc") ##' unique(pk[,c("EVID","flagn","flagc","BLQ")]) ##' flagsCount(pk[EVID==0],dt.flags,col.flagn="flagn",col.flagc="flagc") +##' } ##' @export diff --git a/R/lstExtractTime.R b/R/lstExtractTime.R index 11a31016..3ed85266 100644 --- a/R/lstExtractTime.R +++ b/R/lstExtractTime.R @@ -8,11 +8,13 @@ ##' NMdata:::lstExtractTime(file) ##' file <- system.file("examples/nonmem/xgxr003.mod",package="NMdata") ##' NMdata:::lstExtractTime(file) -##' +##' +##' \dontrun{ ##' all.lsts <- list.files( ##' system.file("examples/nonmem",package="NMdata"), ##' pattern="\\.lst",full.names=TRUE) ##' lapply(all.lsts,NMdata:::lstExtractTime) +##' } ##' @keywords internal lstExtractTime <- function(file,tz.lst="as.is"){ diff --git a/R/zzz.R b/R/zzz.R index 1fe8696b..06b9c5d1 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -7,5 +7,5 @@ NMdataConf(reset=TRUE) ##' @importFrom utils packageVersion .onAttach <- function(libname,pkgname){ - packageStartupMessage(paste0("This is NMdata ",packageVersion("NMdata"),". Browse NMdata documentation at\nhttps://philipdelff.github.io/NMdata/")) + packageStartupMessage(paste0("NMdata ",packageVersion("NMdata"),". Browse NMdata documentation at\nhttps://philipdelff.github.io/NMdata/")) } diff --git a/README.Rmd b/README.Rmd index 2fab411e..6b74f854 100644 --- a/README.Rmd +++ b/README.Rmd @@ -61,7 +61,7 @@ the CheatSheet ### How to install -`NMdata` is on [CRAN](https://cran.r-project.org/), [MRAN](https://mran.microsoft.com/), and [MPN](https://mpn.metworx.com). To install from the package archive you are already using, do: +`NMdata` is on [CRAN](https://cran.r-project.org/package=NMdata) and [MPN](https://mpn.metworx.com/docs/packages/NMdata). To install from the package archive you are already using, do: ``` install.packages("NMdata") diff --git a/README.md b/README.md index 51057194..a4afc700 100644 --- a/README.md +++ b/README.md @@ -46,16 +46,15 @@ the [Cheatsheet](https://htmlpreview.github.io/?https://github.com/philipdelff/NMdata/blob/master/vignettes/NMdata-cheat.html). - CheatSheet ### How to install -`NMdata` is on [CRAN](https://cran.r-project.org/), -[MRAN](https://mran.microsoft.com/), and [MPN](https://mpn.metworx.com). -To install from the package archive you are already using, do: +`NMdata` is on [CRAN](https://cran.r-project.org/package=NMdata) and +[MPN](https://mpn.metworx.com/docs/packages/NMdata). To install from the +package archive you are already using, do: install.packages("NMdata") library(NMdata) @@ -120,7 +119,7 @@ ggplot(res.plot,aes(TIME))+ labs(y="Concentration (unit)",colour="Observations", subtitle="NOTICE:\nObservations are coloured by a character column fetched from input data.\nSamples below LLOQ are rows added from input data.\nPlots are correctly sorted because factor levels of dose are preserved from input data.")+ theme_bw()+theme(legend.position="bottom") -#> Warning: Removed 2 row(s) containing missing values (geom_path). +#> Warning: Removed 2 rows containing missing values (`geom_line()`). ``` @@ -156,15 +155,17 @@ 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) -#> No missing values identified +#> Input and output data were searched for candidate unique row identifiers. None +#> found. To skip this check, please use merge.by.row=TRUE or merge.by.row=FALSE. +#> #> #> Overview of model scanning results: -#> lst -#> 1: /tmp/RtmpTd9QIu/temp_libpath102521020f9b7/NMdata/examples/nonmem/xgxr001.lst -#> 2: /tmp/RtmpTd9QIu/temp_libpath102521020f9b7/NMdata/examples/nonmem/xgxr002.lst -#> 3: /tmp/RtmpTd9QIu/temp_libpath102521020f9b7/NMdata/examples/nonmem/xgxr003.lst -#> 4: /tmp/RtmpTd9QIu/temp_libpath102521020f9b7/NMdata/examples/nonmem/xgxr014.lst -#> 5: /tmp/RtmpTd9QIu/temp_libpath102521020f9b7/NMdata/examples/nonmem/xgxr018.lst +#> lst +#> 1: /tmp/Rtmp82nZom/temp_libpath1370126d22f6/NMdata/examples/nonmem/xgxr001.lst +#> 2: /tmp/Rtmp82nZom/temp_libpath1370126d22f6/NMdata/examples/nonmem/xgxr002.lst +#> 3: /tmp/Rtmp82nZom/temp_libpath1370126d22f6/NMdata/examples/nonmem/xgxr003.lst +#> 4: /tmp/Rtmp82nZom/temp_libpath1370126d22f6/NMdata/examples/nonmem/xgxr014.lst +#> 5: /tmp/Rtmp82nZom/temp_libpath1370126d22f6/NMdata/examples/nonmem/xgxr018.lst #> nrows ncols success warning #> 1: 905 40 TRUE FALSE #> 2: 905 34 TRUE FALSE @@ -195,7 +196,7 @@ reached CRAN, installing from Github is easy too. ## Option 2: Install explicitly from CRAN install.packages("NMdata",repos="https://cloud.r-project.org") library(NMdata) - + ## Option 3: Install from github library(remotes) install_github("philipdelff/NMdata") diff --git a/man/NMcheckData.Rd b/man/NMcheckData.Rd index 1c1cba8a..315bec5e 100644 --- a/man/NMcheckData.Rd +++ b/man/NMcheckData.Rd @@ -231,9 +231,11 @@ column. } } \examples{ +\dontrun{ dat <- readRDS(system.file("examples/data/xgxr2.rds", package="NMdata")) NMcheckData(dat) dat[EVID==0,LLOQ:=3.5] ## expecting LLOQ only for samples NMcheckData(dat,cols.num=list(c("STUDY"),"EVID==0"=c("LLOQ"))) } +} diff --git a/man/NMscanData.Rd b/man/NMscanData.Rd index 865e68e6..5bb94917 100644 --- a/man/NMscanData.Rd +++ b/man/NMscanData.Rd @@ -212,8 +212,10 @@ list of known limitations: } } \examples{ +\dontrun{ res1 <- NMscanData(system.file("examples/nonmem/xgxr001.lst", package="NMdata")) } +} \seealso{ Other DataRead: \code{\link{NMreadCsv}()}, diff --git a/man/NMscanMultiple.Rd b/man/NMscanMultiple.Rd index 492bd6c5..ee95dfb0 100644 --- a/man/NMscanMultiple.Rd +++ b/man/NMscanMultiple.Rd @@ -33,9 +33,11 @@ in one folder and can be read with NMscanData using the same arguments. } \examples{ +\dontrun{ res <- NMscanMultiple(dir=system.file("examples/nonmem", package="NMdata"), file.pattern="xgxr01.*\\\\.lst",as.fun="data.table") res.mean <- res[,.(meanPRED=exp(mean(log(PRED)))),by=.(model,NOMTIME)] library(ggplot2) -ggplot(res.mean,aes(NOMTIME,meanPRED,colour=model))+geom_line() +ggplot(res.mean,aes(NOMTIME,meanPRED,colour=model))+geom_line() +} } diff --git a/man/NMwriteData.Rd b/man/NMwriteData.Rd index 5b3aac11..742ed98d 100644 --- a/man/NMwriteData.Rd +++ b/man/NMwriteData.Rd @@ -69,9 +69,9 @@ NMdataConf.} function that generates text suggestion for INPUT and DATA sections in the Nonmem control stream. You can use these arguments to get a text suggestion you an use directly in -Nonmem - and NMwriteSection can even update multiple Nonmem -control streams based on the result. This will update your -control streams to match your new data file with just one +Nonmem - and \code{NMwriteSection} can even update multiple +Nonmem control streams based on the result. This will update +your control streams to match your new data file with just one command.} \item{csv.trunc.as.nm}{If TRUE, csv file will be truncated @@ -93,8 +93,8 @@ Nonmem.} \item{save}{Save defined files? Default is TRUE. If a variable is used to control whether a script generates outputs (say -`writeOutputs=TRUE/FALSE`), if you use `save=writeOutputs` to -comply with this.} +\code{writeOutputs=TRUE/FALSE)}, if you use +\code{save=writeOutputs} to comply with this.} \item{write.csv}{Write to csv file? Deprecated, use `formats.write` instead.} diff --git a/man/figures/README-NMscanData-example1-plot-1.png b/man/figures/README-NMscanData-example1-plot-1.png index 71585af9..52ff63c8 100644 Binary files a/man/figures/README-NMscanData-example1-plot-1.png and b/man/figures/README-NMscanData-example1-plot-1.png differ diff --git a/man/figures/README-unnamed-chunk-2-1.png b/man/figures/README-unnamed-chunk-2-1.png index a88b60e7..85a4fe35 100644 Binary files a/man/figures/README-unnamed-chunk-2-1.png and b/man/figures/README-unnamed-chunk-2-1.png differ diff --git a/man/findCovs.Rd b/man/findCovs.Rd index 946ce277..88a4ec84 100644 --- a/man/findCovs.Rd +++ b/man/findCovs.Rd @@ -51,11 +51,13 @@ findVars(findCovs(dt1,"ID")) ## occasion level findCovs(findVars(dt1,"ID"),c("ID","OCC")) ## Based on a "real data example" +\dontrun{ dat <- NMscanData(system.file("examples/nonmem/xgxr001.lst", package = "NMdata")) findCovs(dat,by="ID") ### Without an ID column we get non-varying columns findCovs(dat) } +} \seealso{ Other DataCreate: \code{\link{NMorderColumns}()}, diff --git a/man/flagsAssign.Rd b/man/flagsAssign.Rd index 23c36155..d068277a 100644 --- a/man/flagsAssign.Rd +++ b/man/flagsAssign.Rd @@ -77,6 +77,7 @@ dt.flags must contain a column with numerical exclusion of the numerical exclusion flag. } \examples{ +\dontrun{ pk <- readRDS(file=system.file("examples/data/xgxr2.rds",package="NMdata")) dt.flags <- data.frame( flagn=10, @@ -89,6 +90,7 @@ pk <- flagsAssign(pk,subset.data="EVID==1",flagc.0="Dosing", unique(pk[,c("EVID","flagn","flagc","BLQ")]) flagsCount(pk[EVID==0],dt.flags,col.flagn="flagn",col.flagc="flagc") } +} \seealso{ Other DataCreate: \code{\link{NMorderColumns}()}, diff --git a/man/flagsCount.Rd b/man/flagsCount.Rd index 30ba2eb1..62f375ca 100644 --- a/man/flagsCount.Rd +++ b/man/flagsCount.Rd @@ -104,6 +104,7 @@ In the returned table, N.discarded is the difference in number of have been discarded by earlier flags. } \examples{ +\dontrun{ pk <- readRDS(file=system.file("examples/data/xgxr2.rds",package="NMdata")) dt.flags <- data.frame( flagn=10, @@ -116,6 +117,7 @@ pk <- flagsAssign(pk,subset.data="EVID==1",flagc.0="Dosing", unique(pk[,c("EVID","flagn","flagc","BLQ")]) flagsCount(pk[EVID==0],dt.flags,col.flagn="flagn",col.flagc="flagc") } +} \seealso{ Other DataCreate: \code{\link{NMorderColumns}()}, diff --git a/man/lstExtractTime.Rd b/man/lstExtractTime.Rd index 663ae9fb..0fd06f5e 100644 --- a/man/lstExtractTime.Rd +++ b/man/lstExtractTime.Rd @@ -21,9 +21,11 @@ NMdata:::lstExtractTime(file) file <- system.file("examples/nonmem/xgxr003.mod",package="NMdata") NMdata:::lstExtractTime(file) +\dontrun{ all.lsts <- list.files( system.file("examples/nonmem",package="NMdata"), pattern="\\\\.lst",full.names=TRUE) lapply(all.lsts,NMdata:::lstExtractTime) } +} \keyword{internal}