NMorderColumns: Standardize column order in Nonmem input data

View source: R/NMorderColumns.R

NMorderColumnsR Documentation

Standardize column order in Nonmem input data

Description

Order data columns for easy export to Nonmem. No data values are edited. The order is configurable through multiple arguments. See details.

Usage

NMorderColumns(
  data,
  first,
  last,
  lower.last = FALSE,
  chars.last = TRUE,
  alpha = TRUE,
  col.nomtime,
  col.time = "TIME",
  col.row,
  col.flagn,
  col.dv = "DV",
  as.fun = NULL,
  quiet
)

Arguments

data

The dataset which columns to reorder.

first

Columns that should come almost first. See details.

last

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.

lower.last

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.

chars.last

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 ".".

alpha

Sort columns alphabetically. Notice, this is the last order priority applied.

col.nomtime

The name of the column containing nominal time. If given, it will put the column quite far left, just after row counter and ID. Default value is NOMTIME and can be configured with NMdataConf.

col.time

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.

col.row

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.

col.flagn

The name of the column containing numerical flag values for data row omission. Default value is FLAG and can be configured with NMdataConf.

col.dv

a vector of column names to put early to represent dependent variable(s). Default is DV.

as.fun

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.

quiet

If true, no warning will be given about missing standard Nonmem columns.

Details

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.

"col.row - "

Row id if argument row is non-NULL

"not editable - "

ID (if a column is called ID)

"col.nomtime - "

Nominal time.

"col.time - "

Actual time.

"first - "

user-specified first columns

"Only col.dv editable - "

Standard Nonmem columns: EVID, CMT, AMT, RATE, col.dv, MDV

"last - "

user-specified last columns

"chars.last - "

numeric, or interpretable as numeric

"not editable - "

less often used Nonmem names: col.flagn, OCC, ROUTE, GRP, TRIAL, DRUG, STUDY

"lower.last - "

lower case in name

"alpha - "

Alphabetic/numeric sorting

Value

data with modified column order.

See Also

Other DataCreate: NMstamp(), NMwriteData(), addTAPD(), findCovs(), findVars(), flagsAssign(), flagsCount(), mergeCheck(), tmpcol()


NMdata documentation built on Nov. 11, 2023, 5:07 p.m.