Learn R Programming

cobalt (version 1.3.0)

f.build: Convenient Formula Generation

Description

f.build() returns a formula of the form y ~ x1 + x2 + ... from a data frame input. It can be much quicker to use f.build() than to hand-write the precise formula, which may contain errors. It can be used in place of a formula in, for example, glm(), matchit(), or bal.tab().

Usage

f.build(y, rhs)

Arguments

y
the quoted name of the response (left hand side) variable in the formula. Only one variable is supported.
rhs
a data frame whose variable names will be the terms on the right hand side of the formula, or a character vector whose values will be the terms on the right hand side of the formula.

Value

an object of class "formula".

Examples

Run this code
data(lalonde)
covs <- subset(lalonde, select = -c(treat, re78))
lm(f.build("treat", covs), data = lalonde)

Run the code above in your browser using DataLab