Learn R Programming

GRAB (version 0.2.2)

handleFormula: handle a formula (used in GRAB.NullModel function)

Description

handle a formula (used in GRAB.NullModel function), this function can help users better understand the input of GRAB.NullModel() function

Usage

handleFormula(formula, data, subset, subjData)

Value

an R list with elements of 'response', 'designMat', and 'subjData'.

Arguments

formula

a formula object, with the response on the left of a ~ operator and the covariates on the right. Do not add a column of intercept (e.g. a vector of ones) on the right. Missing values should be denoted by NA and the corresponding samples will be removed from analysis.

data

a data.frame in which to interpret the variables named in the formula, or in the subset argument. Check ?model.frame for more details.

subset

a specification of the rows to be used: defaults to all rows. This can be any valid indexing vector for the rows of data or if that is not supplied, a data frame made up of the variables used in formula. Check ?model.frame for more details.

subjData

a character vector of subject IDs. Its order should be the same as the subjects order in the formula and data.

Examples

Run this code
n <- 20
subjData <- paste0("ID-", 1:n)
pheno <- rbinom(n, 1, 0.5)
x1 <- rnorm(n)
x2 <- rnorm(n)
x3 <- rbinom(n, 2, 0.5)
objFormula <- handleFormula(pheno ~ x1 + x2 * x3, subset = x2 > 0, subjData = subjData)
objFormula

Run the code above in your browser using DataLab