Generate an overview of number of observations disregarded due to different reasons. And how many are left after each exclusion flag.

  file, = "ID",
  by = NULL,
  flags.increasing = FALSE,
  flagc.0 = "Analysis set", = "All available data",
  grp.incomp = "EVID",
  save = TRUE, = NULL



The dataset including both FLAG and flag columns.


A data.frame containing at least these named columns: FLAG, flag, condition. Condition is disregarded for FLAG==0.


A file to write the table of flag counts to. Will probably be removed and put in a separate function.

The name of the subject ID column. Default is "ID".


The name of the column containing the numerical flag values in tab.flags. This will be added to data. Use the same as when flagsAssign was called (if that was used). Default value is FLAG and can be configured using NMdataConf.


The name of the column containing the character flag values in data and tab.flags. Use the same as when flagsAssign was called (if that was used). Default value is flag and can be configured using NMdataConf.


An optional column to group the counting by. This could be "STUDY", "DRUG", "EVID", or a combination of multiple columns.


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.


The character flag to assign to rows that are not matched by exclusion conditions (numerical flag 0).

What to call the total set of data before applying exclusion flags. Default is "All available data".


Column(s) that distinct incompatible subsets of data. Default is "EVID" meaning that if different values of EVID are found in data, the function will return an error. This is a safeguard not to mix data unintentionally when counting flags.


Save file? Default is TRUE, meaning that a file will be written if file argument is supplied.

The default is to return a data.table if input data is a data.table, and return a data.frame for all other input classes. Pass a function in to convert to something else. If data is not a data.table, default can be configured using NMdataConf.


A summary table with number of discarded and retained subjects and observations when applying each condition in the flag table. "discarded" means that the reduction of number of observations and subjects resulting from the flag, "retained" means the numbers that are left after application of the flag. The default is "both" which will report both. Class as defined by


This function is used to count flags as assigned by the flagsAssign function.

Notice that the character flags reported in the output table are taken from tab.flags. The data column named by the value of col.flagc (default is flag) is not used.

In the returned table, N.discarded is the difference in number of subjects since previous step. If two is reported, it can mean that the remaining one observation of these two subjects are discarded due to this flag. The majority of the samples can have been discarded by earlier flags.

See also


if (FALSE) {
pk <- readRDS(file=system.file("examples/data/xgxr2.rds",package="NMdata"))
dt.flags <- data.frame(
       flagc="Below LLOQ",
pk <- flagsAssign(pk,dt.flags,"EVID==0",col.flagn="flagn",col.flagc="flagc")
pk <- flagsAssign(pk,"EVID==1",flagc.0="Dosing",