Order data columns for easy export to Nonmem. No data values are edited. The order is configurable through multiple arguments. See details.
NMorderColumns(
data,
first,
last,
lower.last = FALSE,
chars.last = TRUE,
alpha = TRUE,
col.id,
col.nomtime,
col.time,
col.row,
col.flagn,
col.dv = "DV",
allow.char.TIME = TRUE,
as.fun = NULL,
quiet
)
The dataset which columns to reorder.
Columns that should come almost first. See details.
Columns to move to back of dataset. If you work with a large dataset, and some columns are irrelevant for the Nonmem runs, you can use this argument.
Should columns which names contain lowercase characters be moved towards the back? Some people use a standard of lowercase variables (say "race") being character representations ("Asian", "Caucasian", etc.) variables and the uppercase (1,2,...) being the numeric representation for Nonmem.
Should columns which cannot be converted to numeric be put towards the end? A column can be a character or a factor in R, but still be valid in Nonmem (often the case for ID which can only contain numeric digits but really is a character or factor). So rather than only looking at the column class, the columns are attempted converted to numeric. Notice, it will attempted to be converted to numeric to test whether Nonmem will be able to make sense of it, but the values in the resulting dataset will be untouched. No values will be edited. If TRUE, logicals will always be put last. NA's must be NA or ".".
Sort columns alphabetically. Notice, this is the last order priority applied.
Name of the (numeric) unique subject ID. Can be controlled with `NMdataConf()`.
The name of the column containing nominal time. If given, it will put the column quite far left, just after row counter and `col.id`. Default value is NOMTIME and can be configured with `NMdataConf()`.
The name of the column containing actual time. If given, it will put the column quite far left, just after row counter, subject ID, and nominal time. Default value is `TIME`. Can be controlled with `NMdataConf()`.
A row counter column. This will be the first column in the dataset. Technically, you can use it for whatever column you want first. Default value is `ROW` and can be configured with `NMdataConf()`.
The name of the column containing numerical flag values for data row omission. Default value is FLAG and can be configured with `NMdataConf()`.
a vector of column names to put early to represent dependent variable(s). Default is DV.
For the $INPUT text proposal only. Assume Nonmem can read TIME and DATE even if it can't be translated to numeric. This is necessary if using the 00:00 format. Default is TRUE.
The default is to return a data.table if data is a data.table and return a data.frame in all other cases. Pass a function in as.fun to convert to something else. The default can be configured using `NMdataConf()`. However, if data is a data.table, settings via `NMdataConf()` are ignored.
If true, no warning will be given about missing standard Nonmem columns.
data with modified column order.
This function will change the order of columns but it will never edit values in any columns. The ordering is by the following steps, each step depending on corresponding argument.
Row id if argument row is non-NULL
ID (if a column is called ID)
Nominal time.
Actual time.
user-specified first columns
Standard Nonmem columns: EVID, CMT, AMT, RATE, col.dv, MDV
user-specified last columns
numeric, or interpretable as numeric
less often used Nonmem names: col.flagn, OCC, ROUTE, GRP, TRIAL, DRUG, STUDY
lower case in name
Alphabetic/numeric sorting
Other DataCreate:
NMstamp()
,
NMwriteData()
,
addTAPD()
,
findCovs()
,
findVars()
,
flagsAssign()
,
flagsCount()
,
mergeCheck()
,
tmpcol()