Home > Mobile >  Changing the tickmark labels in a plot call from a lattice-based call
Changing the tickmark labels in a plot call from a lattice-based call

Time:11-29

Is there a way to change the tickmark labels (the two labels in red below) in the plot(allEffects(), ...) call below?

I want to change them to "A" and "B" inside the plot(m1, ...) only (NOT via the CO2 data or the m1 model).

The ?effects::plot.eff doesn't seem to provide much guidence.

#================ Fully Reproducible Example
library(effects)

m1 <- lm(uptake ~ Treatment, data = CO2)
plot(allEffects(m1))

enter image description here

CodePudding user response:

We may change the xlevels of 'Treatment' in the model

library(effects)
m1$xlevels$Treatment <- c("A", "B")
plot(allEffects(m1))

-output

enter image description here


If we don't want to change the model itself, then create an object from the allEffects output and change the levels in that

e1 <- allEffects(m1) 
levels(e1$Treatment$x$Treatment) <- c("B", "A")
e1$Treatment$variables$Treatment$levels <- c("A", "B")
plot(e1)
  • Related