I have been having trouble with running emmeans function (from the emmeans package) whenever I try to follow up a two way between groups ANOVA with estimated marginal means.
A simple example:
library(emmeans)
library(tidyverse)
df <- tibble(fct1 = factor(rep(1:3, 10)),
fct2 = factor(rep(2:1, 15)),
DV = rnorm(30, 100, 15))
model1 <- lm(DV ~ fct1 * fct2, df)
emmeans(model1, "fct1", by = "fct2")
Returns:
Error in assign(".Last.ref_grid", object, inherits = TRUE) :
cannot change value of locked binding for '.Last.ref_grid'
No matter what data I run it on, always the same error shows up.
Thank you for any help!
This should stop it:
emm_options(save.ref_grid = FALSE)
This will keep it from saving the most recently created reference grid (or trying to, in your case). However, it may be worth trying to understand why this is happening. If you do:
.Last.ref_grid
you should see what it is that was last saved. That might be a clue. And try to delete it.