findCovs: Extract columns that do not vary within variables in data

Description Usage Arguments Value See Also Examples

View source: R/findCovs.R

Description

This function provides an automated method to extract covariate-like columns. The user decides which columns these variables cannot vary within. So if you have repeated measures for each ID, this function can find the columns that are constant within ID and their unique values for each ID. Or, you can provide a combination of id.cols, say ID and STUDY, and get variables that do not vary within unique combinations of these.

Usage

1
findCovs(data, by = NULL, as.fun = NULL)

Arguments

data

data.frame in which to look for covariates

by

covariates will be searched for in combinations of values in these columns. Often by will be either empty or ID. But it can also be both say c("ID","DRUG") or c("ID","TRT").

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. If data is not a data.table, the default can be configued using NMdataConf.

Value

a data set with one observation per combination of values of variables listed in by.

See Also

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

Examples

1
2
3
4
5
dat <- NMscanData(system.file("examples/nonmem/xgxr001.lst", package = "NMdata"))
### very common use
findCovs(dat,by="ID")
### Without an ID column we get non-varying columns
findCovs(dat)

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