diff --git a/DESCRIPTION b/DESCRIPTION index 737685af..29a51773 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.1.1.901 +Version: 0.1.1.902 Authors@R: c(person("Philip", "Delff", email = "philip@delff.dk", role = c("aut", "cre"))) Maintainer: Philip Delff <philip@delff.dk> 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/NMscanInput.R b/R/NMscanInput.R index 8b38a45e..e3069405 100644 --- a/R/NMscanInput.R +++ b/R/NMscanInput.R @@ -238,7 +238,7 @@ NMscanInput <- function(file, formats.read, file.mod, dir.data=NULL, setcolorder(meta$tables,intersect(c("source","name","nrow","ncol","firstonly","lastonly","firstlastonly","format","sep","nid","idlevel","has.row","maxLength","full.length","filetype","file.mtime","file.logtime","file"),colnames(meta$tables))) - if(col.id%in%NMinfoDT(data.input,"input.colnames")[,result]) { + if(!is.null(col.id) && col.id%in%NMinfoDT(data.input,"input.colnames")[,result]) { meta$tables[,nid:= data.input.0.trans[,uniqueN(get(col.id.inp))] ] diff --git a/devel/todo.org b/devel/todo.org index 4e65e3c6..32634033 100644 --- a/devel/todo.org +++ b/devel/todo.org @@ -7,7 +7,8 @@ *** DONE Add version to welcome message *** DONE All arguments should be arg.foo rather than argFoo *** TODO [#B] deprecate "default" option in NMdataConf - has no benefit over NULL, so redundant and prevents the use of "default" as an actual param value. + has no benefit over NULL, so redundant and prevents the use of + "default" as an actual param value. *** DONE Allow for say input.txt/output.txt **** NMtransInput *** TODO Support a drop argument diff --git a/man/NMextractText.Rd b/man/NMextractText.Rd index 7ecf611f..c64e1fe9 100644 --- a/man/NMextractText.Rd +++ b/man/NMextractText.Rd @@ -59,7 +59,9 @@ matching line numbers are returned. "text" is default.} \item{keep.name}{Keep the section name in output (say, "$PROBLEM") Default is TRUE. It can only be FALSE, if return="text".} -\item{keep.comments}{Keep comment lines?} +\item{keep.comments}{Keep comment lines? This concerns lines that +consist of only white space and comments; comments after +actual contents are not concerned.} \item{as.one}{If multiple hits, concatenate into one. This will most often be relevant with name="TABLE". If FALSE, a list diff --git a/man/NMgenText.Rd b/man/NMgenText.Rd index 0fda404f..3b8235fa 100644 --- a/man/NMgenText.Rd +++ b/man/NMgenText.Rd @@ -83,7 +83,8 @@ value. If negative or zero, strwrap will not be called.} \item{quiet}{Hold messages back? Default is defined by NMdataConf.} } \value{ -Text for inclusion in Nonmem control stream, invisibly. +Text for inclusion in Nonmem control stream, invisibly. A + list with elements `DATA` and `INPUT`. } \description{ The user is provided with text to use in Nonmem. NMwriteSection diff --git a/man/NMreadCsv.Rd b/man/NMreadCsv.Rd index 6cd73cc7..aaec1361 100644 --- a/man/NMreadCsv.Rd +++ b/man/NMreadCsv.Rd @@ -26,17 +26,16 @@ something else. If data.tables are wanted, use as.fun="data.table". The default can be configured using NMdataConf.} -\item{format}{Format of file to read. Must be one of "csv", "rds", -or "fst". Default is to determine this from the file name -extension. Notice, if a delimited format is used, the -extension can very well be different from "csv" (say file name -is "input.tab"), and one must provide format="csv". This will -work for any delimited format supported by fread and does not -need to be comma-separated even though the format name -indicates so.} +\item{format}{Format of file to read. Can be of length>1 in which +case the first format found will be used (i.e. format is a +prioritized vector). If not one of "rds" or "fst", it is +assumed to be a delimited text file. Default is to determine +this from the file name extension. Notice, if a delimited +format is used, the extension can very well be different from +"csv" (say file name is +"input.tab")". This will work for any delimited format supported by fread.} -\item{args.fst}{Optional arguments to pass to \code{read_fst} if -code{format="fst"} is used.} +\item{args.fst}{Optional arguments to pass to \code{read_fst} if code{format="fst"} is used.} } \value{ A data set of class as defined by as.fun. @@ -46,11 +45,7 @@ This function is especially useful if the csv file was written using NMwriteData. } \details{ -This is almost just a shortcut to fread so you don't have - to remember how to read the data that was exported for - Nonmem. The only added feature is that meta data as written by - NMwriteData is read and attached as NMdata metadata before - data is returned. +This is almost just a shortcut to fread so you don't have to remember how to read the data that was exported for Nonmem. The only added feature is that meta data as written by NMwriteData is read and attached as NMdata metadata before data is returned. } \seealso{ NMwriteData diff --git a/man/NMreadSection.Rd b/man/NMreadSection.Rd index f7461a30..8f494380 100644 --- a/man/NMreadSection.Rd +++ b/man/NMreadSection.Rd @@ -51,7 +51,9 @@ matching line numbers are returned. "text" is default.} \item{keep.name}{Keep the section name in output (say, "$PROBLEM") Default is FALSE. It can only be FALSE, if return="text".} -\item{keep.comments}{Keep comment lines?} +\item{keep.comments}{Keep comment lines? This concerns lines that +consist of only white space and comments; comments after +actual contents are not concerned.} \item{as.one}{If multiple hits, concatenate into one. This will most often be relevant with name="TABLE". If FALSE, a list @@ -92,9 +94,9 @@ suitable for the results part too. } \section{Functions}{ \itemize{ -\item \code{NMgetSection()}: Deprecated function name. Use NMreadSection. - +\item \code{NMgetSection}: Deprecated function name. Use NMreadSection. }} + \examples{ NMreadSection(system.file("examples/nonmem/xgxr001.lst", package="NMdata"),section="DATA") diff --git a/man/NMscanInput.Rd b/man/NMscanInput.Rd index 0c6ca772..c7b785ee 100644 --- a/man/NMscanInput.Rd +++ b/man/NMscanInput.Rd @@ -112,20 +112,15 @@ provided (though not recommended), this will overwrite A data set, class defined by 'as.fun' } \description{ -Based on a Nonmem run (lst and/or mod file), this - function finds the input data and reads it. It reads the data - like the Nonmem run by applying DROP/SKIP arguments and - alternative naming of columns in the Nonmem run. -} -\details{ This function finds and reads the input data based on a control stream file path. It can align the column names to the definitions in $INPUT in the control stream, and it can subset the data based -on ACCEPT/IGNORE statements in $DATA. I supports a few other ways +on ACCEPT/IGNORE statements in $DATA. It supports a few other ways to identify the input data file than reading the control stream, -and it can also read an rds file instead of the delimited text -file used by Nonmem. - +and it can also read an rds or fst file instead of the delimited +text file used by Nonmem. +} +\details{ Columns that are dropped (using DROP or SKIP in $INPUT) in the model will be included in the output. diff --git a/tests/testthat/test_NMscanInput.R b/tests/testthat/test_NMscanInput.R index 5c2585a0..c8adb29b 100644 --- a/tests/testthat/test_NMscanInput.R +++ b/tests/testthat/test_NMscanInput.R @@ -264,6 +264,6 @@ test_that("Combinations of translate and recover.cols",{ all.res <- list(res1,res2,res3,res4) all.res <- lapply(all.res,fix.time) - expect_equal_to_reference(res,fileRef,version=2) + expect_equal_to_reference(all.res,fileRef,version=2) })