Skip to contents

From the right hand side of a formula for a mixed-effects model, determine the pairs of expressions that are separated by the vertical bar operator. Also expand the slash operator in grouping factor expressions and expand terms with the double vertical bar operator into separate, independent random effect terms.

Usage

findbars(term)

Arguments

term

a mixed-model formula

Value

pairs of expressions that were separated by vertical bars

Note

This function is called recursively on individual terms in the model, which is why the argument is called term and not a name like form, indicating a formula.

See also

formula, model.frame, model.matrix.

Other utilities: mkRespMod, mkReTrms, nlformula, nobars, subbars

Examples

  findbars(f1 <- Reaction ~ Days + (Days | Subject))
#> [[1]]
#> Days | Subject
#> 
  ## => list( Days | Subject )
  ## These two are equivalent:% tests in ../inst/tests/test-doubleVertNotation.R
  findbars(y ~ Days + (1 | Subject) + (0 + Days | Subject))
#> [[1]]
#> 1 | Subject
#> 
#> [[2]]
#> 0 + Days | Subject
#> 
  findbars(y ~ Days + (Days || Subject))
#> [[1]]
#> 1 | Subject
#> 
#> [[2]]
#> 0 + Days | Subject
#> 
  ## => list of length 2:  list ( 1 | Subject ,  0 + Days | Subject)
  findbars(~ 1 + (1 | batch / cask))
#> [[1]]
#> 1 | cask:batch
#> 
#> [[2]]
#> 1 | batch
#> 
  ## => list of length 2:  list ( 1 | cask:batch ,  1 | batch)
  # \dontshow{
    stopifnot(identical(findbars(f1),
                        list(quote(Days | Subject))))
  # }