Skip to content
Prev 181233 / 398502 Next

Naming a random effect in lmer

The coding error is right in the error message:
  Error in names(bars) <- unlist(lapply(bars, function(x)
deparse(x[[3]])))
and I suspect that traceback() would tell you that came from a call
to lmerFactorList.

That code implicitly assumes that deparse() will produce a scalar
character
vector, but it doesn't if the input expression is complicated enough.
Changing the
    deparse(x[[3]])
to
    deparse(x[[3]])[1]
or
    paste(collapse=" ", deparse(x[[3]])[1])
would fix it.  The first truncates the name and the second my make a
very
long name.

There is at least one other use of that idiom in the lme4 code and your
dataset and analysis may require that all of them be fixed.