expand_formula: Create formulas by expanding out string vector arguments

View source: R/utils-formula.R

expand_formulaR Documentation

Create formulas by expanding out string vector arguments

Description

Create formulas by expanding out string vector arguments

Usage

expand_formula(formula, ...)

Arguments

formula

An R formula containing terms referencing objects defined in the parent environment or in ... Terms must each consist of a single lowercase or uppercase letter.

...

Variables referenced in formula. Can be glue-style, with glue terms also defined in ... (see examples)

Value

chr.

Examples

expand_formula(~a:b + d, a=c('a1','a2'), b=c('b1','b2'), d='d1')

#we could have equivalently defined any of the variables in the formula in the calling environment:
a=c('a1','a2')
b=c('b1','b2')
d='d1'
expand_formula(~a:b + d)

#variables can be specified in glue-style
expand_formula(~a:b, a=c('a{h}', 'a{h+1}'), b='a{h}', h=1)

audreyrenson/paralleltrends documentation built on May 4, 2022, 2:53 a.m.