I am attempting to use the emmeans package in RStudio, which I have done successfully many times, but now it is giving me an error that I can't solve:
shannon_site_emm <- emmeans(shannon_site, factor(site))
Error in t(OO[[rr]]) : object 'unpackedMatrix_transpose' not found
Specifically, I am re-running a previously used script with an updated dataset, so I know the emmeans package worked before with this project, and the nature of the updates to my dataset aren't dramatic enough that they should be the issue here.
Has anyone come across this error before and know how to fix it?
What I did:
#fit a model:
shannon_site <- lmer(Shannon ~ site + (1|bird_name), data = alpha_metadata)
# inspected parameters:
summary(shannon_site)
Linear mixed model fit by REML. t-tests use Satterthwaite's method ['lmerModLmerTest']
Formula: Shannon ~ site + (1 | bird_name)
Data: alpha_metadata
REML criterion at convergence: 889.7
Scaled residuals:
Min 1Q Median 3Q Max
-2.4094 -0.6484 0.0143 0.5922 2.6900
Random effects:
Groups Name Variance Std.Dev.
bird_name (Intercept) 0.1652 0.4065
Residual 1.2518 1.1188
Number of obs: 281, groups: bird_name, 142
**Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) 3.4142 0.8894 150.4461 3.839 0.000182 ***
siteFt Lauderdale -1.3439 1.0893 150.4461 -1.234 0.219234
siteJDSP 0.3794 0.9889 162.3981 0.384 0.701773
siteSFWC -1.3423 0.9080 152.7540 -1.478 0.141394
siteTTP -0.4431 0.8937 150.0042 -0.496 0.620771
---**
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Correlation of Fixed Effects:
(Intr) stFtLd stJDSP stSFWC
siteFtLdrdl -0.816
siteJDSP -0.899 0.734
siteSFWC -0.980 0.800 0.881
siteTTP -0.995 0.813 0.895 0.975
I have seen this issue before in an issue report. It is not a problem in emmeans. It appears to be some glitch in the transition between R versions and the Matrix package support, possibly. I think if you reinstall some packages (maybe Matrix?) and restart R, the problem will go away. Sorry I can't be more specific, but I do have user-reported success.