flagsAssign: Assign exclusion flags to a dataset based on specified table

Description Usage Arguments Details Value See Also Examples

View source: R/flagsAssign.R

Description

The aim with this function is to take a (say PK) dataset and a pre-specified table of flags, assign the flags automatically.

Usage

1
2
3
4
5
6
7
8
9
flagsAssign(
  data,
  tab.flags,
  subset.data,
  col.flagn,
  col.flagc,
  flags.increasing = FALSE,
  as.fun = NULL
)

Arguments

data

The dataset to assign flags to.

tab.flags

A data.frame containing at least these named columns: FLAG, flag, condition. Condition is disregarded for FLAG==0. FLAG must be numeric and non-negative, flag and condition are characters.

subset.data

An optional string that provides a subset of data to assign flags to. A common example is subset=\"EVID==0\" to only assign to observations. Numerical and character flags will be missing in rows that are not matched by this subset.

col.flagn

The name of the column containing the numerical flag values in tab.flags. This will be added to data. Default value is FLAG and can be configured using NMdataConf.

col.flagc

The name of the column containing the character flag values in tab.flags. This will be added to data. Default value is flag and can be configured using NMdataConf.

flags.increasing

The flags are applied by either decreasing (default) or increasing value of col.flagn. By using decreasing order, you can easily adjust the Nonmem IGNORE statement from IGNORE(FLAG.NE.0) to say IGNORE(FLAG.GT.10) if BLQ's have FLAG=10, and you decide to include these in the analysis.

as.fun

The default is to return data.tables if input data is a data.table, and return a data.frame for all other input classes. Pass a function in as.fun to convert to something else. If return.all=FALSE, this is applied to data and tab.flags independently.

Details

dt.flags must contain a column with numerical exclusion flags, one with character exclusion flags, and one with a expressions to evaluate for whether to apply the exclusion flag. The flags are applied sequentially, by increasing value of the numerical exclusion flag.

Value

The dataset with flags added. Class as defined by as.fun. See parameter flags.return as well.

See Also

Other DataCreate: NMorderColumns(), NMstamp(), findCovs(), findVars(), flagsCount(), mergeCheck(), tmpcol()

Examples

1
2
3
4
5
6
7
8
9
pk <- readRDS(file=system.file("examples/data/xgxr2.rds",package="NMdata"))
dt.flags <- data.frame(
       flagn=10,
       flagc="Below LLOQ",
       condition=c("BLQ==1")
)
pk <- flagsAssign(pk,dt.flags,col.flagn="flagn",col.flagc="flagc")
unique(pk[,c("flagn","flagc","BLQ")])
flagsCount(pk[EVID==0],dt.flags,col.flagn="flagn",col.flagc="flagc")

NMdata documentation built on Aug. 10, 2021, 1:06 a.m.