Error: 'cld' is not an exported object from 'namespace:emmeans'

274 views Asked by At

I run the following lines from https://rdrr.io/cran/emmeans/f/vignettes/re-engineering-clds.Rmd#equiv-CLDs but got Error in UseMethod("cld") : no applicable method for 'cld' applied to an object of class "emmGrid"

set.seed(22.10)
mu = c(16, 15, 19, 15, 15, 17, 16)  # true means
n =  c(19, 15, 16, 18, 29,  2, 14)  # sample sizes
foo = data.frame(trt = factor(rep(LETTERS[1:7], n)))
foo$y = rnorm(sum(n), mean = mu[as.numeric(foo$trt)], sd = 1.0)

foo.lm = lm(y ~ trt, data = foo)
foo.emm = emmeans(foo.lm, "trt")

library(multcomp)
cld(foo.emm)

Clearing cache and history, restarting R, and restarting the computer does not help.

2

There are 2 answers

0
akrun On

Using 1.4.49 version of multcomp

library(multcomp)
> cld(foo.emm)
 trt emmean    SE  df lower.CL upper.CL .group
 B     14.6 0.246 106     14.1     15.1  1    
 E     15.0 0.177 106     14.6     15.3  1    
 D     15.3 0.224 106     14.8     15.7  1    
 G     15.3 0.254 106     14.8     15.9  1    
 A     16.4 0.218 106     15.9     16.8   2   
 F     16.6 0.673 106     15.2     17.9  12   
 C     19.3 0.238 106     18.9     19.8    3  
0
geosol On

Installing the multcompView package fixed the issue for me. I ran into this after updating to R version 4.3 and installing the latest multcomp and emmeans packages.

Not enough rep to add a comment, just thought I'd add in case anyone is still bumping into this.