library(marginaleffects)
mod <- lm(mpg ~ hp * drat * factor(am), data = mtcars)
plot_cme(mod, effect = "hp", condition = "drat")
plot_cme(mod, effect = "hp", condition = c("drat", "am"))
plot_cme(mod, effect = "hp", condition = list("am", "drat" = 3:5))
plot_cme(mod, effect = "am", condition = list("hp", "drat" = range))
plot_cme(mod, effect = "am", condition = list("hp", "drat" = "threenum"))
Run the code above in your browser using DataLab