Home > Enterprise >  emmeans:emmip_ggplot error "Error in emms$LCL : $ operator not defined for this S4 class"
emmeans:emmip_ggplot error "Error in emms$LCL : $ operator not defined for this S4 class"

Time:11-03

I'm trying the emmip_ggplot with this example

n.emms <- emmeans(neuralgia.glm, ~ Treatment)

emmip_ggplot(n.emms, style = "factor")
Error in emms$LCL : $ operator not defined for this S4 class

emmip(neuralgia.glm, ~Treatment) gives a traditional plot, without error or warning.

enter image description here

Thanks for stopping by.

CodePudding user response:

?emmip_ggplot says the first argument to emmip_ggplot should be

A ‘data.frame’ created by calling ‘emmip’ with ‘plotit = FALSE’. Certain variables and attributes are expected to exist in this data frame; see the section detailing the rendering functions.

Thus

m1 <- glm(vs~hp disp drat, family = binomial, mtcars)
em1 <- emmeans(m1, ~ disp * hp, at = list(hp = 50:300))
em2 <- emmip(em1, disp ~ hp, plotit = FALSE)
emmip_ggplot(em2)

This works (i.e. produces a plot) but I'm not sure it makes sense, as I threw the example together in a hurry.

  • Related