Consider the following dataframe and glmer model:
Dataframe
hunger <- sample(x = 0:1, size = 50, replace = TRUE)
treat <- sample(x = c("A1","A2"), prob = c(.75, .25), size = 50, replace = TRUE)
owner <- sample(x = c("Alice","Ben"), prob = c(.5, .5), size = 50, replace = TRUE)
animal <- sample(x = c("d","cat","cow"), prob = c(.33, .33, .33), size = 50, replace = TRUE)
df <- as.data.frame(cbind(animal,treat,owner,hunger))
df$hunger <- as.numeric(df$hunger)
df$animal <- as.factor(df$animal)
Model
testM <- glmer(hunger ~ animal + treat + animal*treat +
(1 + animal + treat + animal*treat||owner), data = df, family="binomial", glmerControl(optimizer="bobyqa", optCtrl = list(maxfun=1e5)))
summary(testM)
and I visualize the model using ggcoef_model as such:
ggcoef_model(testM, include = !contains(c("owner","Residual.sd")))
this produces the plot:
as we can see under “animal” one of the levels is named “d” – (1) how can I change this label to “dog”? In addition, I would also like to hide the visualization of the level “A1” under “treat”. (2) How can I hide particular levels of a variable?
I can see that here are ways to manipulate the variable labels (i.e. via set_variable_labels(treat = “Treat for the Animal”)), but how do can I manipulate the labels of the levels within a variable?