Skip to contents

Parse formula in format outcome ~ fixed_effect1 + fixed_effect2 + ... (1 | random_effect1) + (1 | random_effect2) + ...

Usage

parse_formula(formula)

Arguments

formula

Formula that describes variables

Value

list with outcome, fixed, random and all fields

Examples

# only one fixed effect
parse_formula(y ~ x)
#> $outcome
#> [1] "y"
#> 
#> $fixed
#> [1] "x"
#> 
#> $random
#> NULL
#> 
#> $all
#> [1] "x" "y"
#> 

# two fixed effects
parse_formula(y ~ x1 + x2)
#> $outcome
#> [1] "y"
#> 
#> $fixed
#> [1] "x1" "x2"
#> 
#> $random
#> NULL
#> 
#> $all
#> [1] "x1" "x2" "y" 
#> 

# one random effect
parse_formula(y ~ (1|z))
#> $outcome
#> [1] "y"
#> 
#> $fixed
#> character(0)
#> 
#> $random
#> [1] "z"
#> 
#> $all
#> [1] "z" "y"
#> 

# one fixed and two random effects
parse_formula(y ~ x + (1|z1) + (1|z2))
#> $outcome
#> [1] "y"
#> 
#> $fixed
#> [1] "x"
#> 
#> $random
#> [1] "z1" "z2"
#> 
#> $all
#> [1] "x"  "z1" "z2" "y" 
#>