Anna
Anna

Reputation: 187

Error "unused argument (env = environment(f)" in lme4

I am trying to perform an lmer in R, from the lme4 package, but I keep getting the error :

Error in reformulate(paste0("(", vapply(findbars(f), deparse1, ""), ")"), : unused argument (env = environment(f))".

Any ideas? Example with iris:

library(lme4)
lmer(iris$Sepal.Length ~ iris$Sepal.Width + (1|iris$Species))

(I know this doesn't make much sense intuitively, but as an example)

Upvotes: 1

Views: 653

Answers (1)

Ben Bolker
Ben Bolker

Reputation: 226911

This is a bug/incompatibility between the current (CRAN) version of lme4, 1.1-28, and versions of R older than 3.6.0. From the r-sig-mixed-models mailing list:

This is a bug that was recently noted (and fixed in the development version) here: https://github.com/lme4/lme4/issues/664
Running this code snippet

assign('reformulate', envir = topenv(),
                function(..., env = parent.env) {
                    f <- base::reformulate(...)
                    environment(f) <- env
                    return(f)
                })

might fix the problem.

Alternately, if you have development tools (compilers etc.) installed on your computer, remotes::install_github("lme4/lme4") will install the development version (which should also fix the problem).

Or you can install a more recent version of R (which might be the best solution and save you future headaches) — see instructions here for installing an up-to-date version of R on Ubuntu.

Upvotes: 1

Related Questions