1

Trying to figure out this error message on RStudio : "Error in UseMethod("cld") : no applicable method for 'cld' applied to an object of class "c('emm_list', 'list')"" I'm confused as it was working yesterday... I was able to display my ggplot with my tukey classes.

Code :

require(multcomp)
require(ggpubr)
require(multcompView)
require(car)
require(ggplot2)
require(lsmeans)
require(emmeans)

M <- read.csv("C:\\Users\\pauli\\Documents\\ISARA 5A\\MFE\\R\\Matrices\\Matrice moisson .csv", sep = ";", dec= ",")

MC <- M[M$parcelle=="Charignon ", ]

MC$distance <- factor(MC$distance, levels=c("1H","2H","6H","12H","15H"))

lm1 <- lm(prot~distance, data=MC) 

res.lm1 <-lsmeans(lm1, pairwise ~ distance,  adjust="tukey")
summary(res.lm1)

res.CLD<-cld(res.lm1, alpha=0.05, Letters=letters)
res.CLD
res.CLD<-res.CLD[res.CLD$.group!='',]

a <- ggplot(data=MC, aes(x=distance, y=prot,col=distance))+
  scale_color_brewer(palette = "Dark2")+
  scale_alpha(0.5)+
  geom_jitter(position = position_jitterdodge(jitter.width = 0), size = 1.5)+
  ylim(0, max(MC$prot)) +
  stat_summary(fun.data=mean_sd, size=0.2, col="black")+
  labs(title = "Parcelle blé dur - CHA", x= "Distance", y="Taux de protéines (%)")+
  theme(legend.position = "none")+
  geom_text(data = res.CLD, aes(x=res.CLD$x, y =10, label=res.CLD$Letters), col="black" ,vjust=0, size=5)
a

I'm trying to get classes from the tukey test and display them on my ggplot.

  • 1
    What does `sessionInfo()` show? Are you sure `library(emmeans)` ran successfully? (it's better to use `library()` at the top of scripts rather than `require()` because they will error if they fail -- `require()` is better for use inside of function or conditional checks) – MrFlick Jul 28 '23 at 12:49
  • sessionInfo() show "other attached packages: [1] lsmeans_2.30-0 car_3.1-2 carData_3.0-5 multcompView_0.1-9 [5] ggpubr_0.6.0 ggplot2_3.4.2 multcomp_1.4-25 TH.data_1.1-2 [9] MASS_7.3-58.4 survival_3.5-5 mvtnorm_1.2-2 emmeans_1.8.7 " library(emmeans) is working. I've changed require() with library() – Pauline Lefranc Jul 28 '23 at 16:01
  • This should work. I think the packages got out of sync with one another and that you will be able to get it to work correctly if you start a new R session. – Russ Lenth Jul 28 '23 at 18:54

0 Answers0