Instead of trying to remember the arguments to pass to write.csv, use this wrapper. It tells you what to write in $DATA and $INPUT in Nonmem, and it (additionally) exports an rds file as well which is highly preferable for use in R. It never edits the data before writing the datafile. The filenames for csv, rds etc. are derived by replacing the extension to the filename given in the file argument.
NMwriteData(
data,
file,
formats.write = c("csv", "rds"),
script,
args.stamp,
args.fwrite,
args.rds,
args.RData,
args.write_fst,
quiet,
args.NMgenText,
csv.trunc.as.nm = FALSE,
genText = TRUE,
save = TRUE,
write.csv,
write.rds,
write.RData,
nm.drop,
nmdir.data,
col.flagn,
nm.rename,
nm.copy,
nm.capitalize,
allow.char.TIME
)
The dataset to write to file for use in Nonmem.
The file to write to. The extension (everything after and including last ".") is dropped. csv, rds and other standard file name extensions are added.
character vector of formats.write. Default is
c("csv","rds"). "fst" is possible too. Default can be modified
with NMdataConf()
.
If provided, the object will be stamped with this script name before saved to rds or RData. See ?NMstamp.
A list of arguments to be passed to NMstamp.
List of arguments passed to fwrite. Notice that except for "x" and "file", you need to supply all arguments to fwrite if you use this argument. Default values can be configured using NMdataConf.
A list of arguments to be passed to saveRDS.
A list of arguments to be passed to save. Please note that writing RData is deprecated.
An optional list of arguments to be passed to write_fst.
The default is to give some information along the way on what data is found. But consider setting this to TRUE for non-interactive use. Default can be configured using NMdataConf.
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
command.
If TRUE, csv file will be truncated horizontally (columns will be dropped) to match the $INPUT text generated for Nonmem (genText must be TRUE for this option to be allowed). This can be a great advantage when dealing with large datasets that can create problems in parallellization. Combined with write.rds=TRUE, the full data set will still be written to an rds file, so this can be used when combining output and input data when reading model results. This is done by default by NMscanData. This means writing a lean (narrow) csv file for Nonmem while keeping columns of non-numeric class like character and factor for post-processing.
Run and report results of NMgenText? Default is TRUE. You may want to disable this if data set is not for Nonmem.
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.
Write to csv file? Deprecated, use `formats.write` instead.
write an rds file? Deprecated, use `formats.write` instead.
Deprecated and not recommended - will be removed. RData is not a adequate format for a dataset (but is for environments). Please use write.rds instead.
Deprecated, use args.NMgenText=list(drop=c("column")) instead.
Deprecated, use args.NMgenText=list(dir.data="your/path") instead.
Name of a numeric column with zero value for rows to include in Nonmem run, non-zero for rows to skip. The argument is only used for generating the proposed $DATA text to paste into the Nonmem control stream. To skip this feature, use col.flagn=NULL.
Deprecated, use args.NMgenText=list(rename=c(newname="existing")) instead.
Deprecated, use args.NMgenText=list(copy=c(newname="existing")) instead.
Deprecated, use args.NMgenText=list(capitalize=TRUE) instead.
Deprecated, use args.NMgenText=list(allow.char.TIME=TRUE) instead.
Text for inclusion in Nonmem control stream, invisibly.
When writing csv files, the file will be comma-separated. Because Nonmem does not support quoted fields, you must avoid commas in character fields. An error is returned if commas are found in strings.
The user is provided with text to use in Nonmem. This lists names of the data columns. Once a column is reached that Nonmem will not be able to read as a numeric and column is not in nm.drop, the list is stopped. Only exception is TIME which is not tested for whether character or not.
Other DataCreate:
NMorderColumns()
,
NMstamp()
,
addTAPD()
,
findCovs()
,
findVars()
,
flagsAssign()
,
flagsCount()
,
mergeCheck()
,
tmpcol()