m-clark / mixedup

An R package for extracting results from mixed models that are easy to use and viable for presentation.
http://m-clark.github.io/mixedup
MIT License
67 stars 2 forks source link

**Summarise_model** returns *'Error: Can't transform a data frame with duplicate names.'* #19

Closed russell-ligon closed 3 years ago

russell-ligon commented 3 years ago

I am running into an issue when I call 'summarise_model' on a mixed model object (class = "lmerModLmerTest"). The error returned is: "Error: Can't transform a data frame with duplicate names."

FWIW, @m-clark has worked with a dummy dataset I sent to him and found NO errors (suggesting, perhaps some versioning issue). That said, we are both running the same versions of 'dplyr', 'lme4', and 'mixedup' (1.0.2, 1.1.26, 0.3.8 respectively). My R version is 3.6.3 (and his is 4.0.3). Will update my R and see what happens...

head(dfs2) Growth Days StartingValue V4 1 0.0 1.2133686 0.4694595 XZ92877 2 1.2 0.5078494 0.4694595 XZ92877 3 0.5 0.7492574 0.4694595 XZ92877 4 1.5 0.5078494 0.3097708 TR59858 5 1.7 0.7492574 0.3097708 TR59858 6 0.0 1.2133686 0.3097708 TR59858

lmer_fit2 <- lmer(Growth ~ Days*StartingValue + (1|V4), data = dfs2) summarise_model(lmer_fit2,ci=FALSE) Error: Can't transform a data frame with duplicate names. Run rlang::last_error() to see where the error occurred.

russell-ligon commented 3 years ago

"MASKING" was the problem --- I was running lmer and had also loaded the package lmerTest!

When I ran the model using lme4::lmer the error went away. Hope this helps somebody else!

To reiterate, create your models with lmer specifically from lme4. Happy analyzing and thanks Michael!

m-clark commented 3 years ago

Thanks for opening and continuing to look into this! This is good to know. Maybe I can add a check/warning or in the documentation somewhere.

m-clark commented 3 years ago

@russell-ligon It should error now with a message to rerun the model with lme4::lmer. The primary problem seemed to be with extract_fixed_effects, so at least some other functions still would work with an lmerModLmerTest object, just not any that would use extract_fixed_effects. I could potentially work around it so it'd work with those objects, but that may not be any time soon.