parse_formula: Parse model formula.

Description Usage Arguments Value

View source: R/formula_.R

Description

Parse model formula, create new variables by evaluating expressions and return parsed names and new data frame. These elements are ment to be used by other functions.

Usage

1
parse_formula(formula, data = NULL, keep_all_vars = FALSE)

Arguments

formula

A stats::formula() of form:

  • ~ y;

  • ~ y1 + y2;

  • y ~ x;

  • y1 + y2 ~ x1 + x2;

  • ~ y|condition;

  • y ~ x|condition;

  • y1 + y2 ~ x1 + x2|cond1 + cond2;

  • or similar.

Variables can be expressed as function, e.g., log(x), as.factor(x), which will be evaluated. Dot (.) is not accepted.

data

A data frame.

keep_all_vars

(logical) Flag indicating if all variables (even those not in formula) should be included in the output data. Expression keep_all_vars = TRUE has effect only if data is a data frame (and not NULL or an environment).

Value

A list with fields:

  1. formula - the formula used;

  2. names - alist of character vectors with names in formula arranged in certain way (see below);

  3. data - a data frame with variables and evaluated expressions in the formula and, optionally, with the remaining variables from the original data frame.

Contents of the field names:


GegznaV/BioStat documentation built on Aug. 14, 2020, 9:30 p.m.