Let's say I have defined a variable (var
) which is the name of a predictor in the model
libary(emmeans)
var <- "disp"
lm.mod <- lm(mpg ~ disp + hp, data=mtcars)
When I try to use the variable var
in the at
argument of emmeans
, it gets ignored
emmeans(lm.mod, var, at=list(var=c(100,200,300,400)))
disp emmean SE df lower.CL upper.CL
231 20.1 0.553 29 19 21.2
using disp
instead, I get the expected output:
emmeans(lm.mod, var, at=list(disp=c(100,200,300,400)))
disp emmean SE df lower.CL upper.CL
100 24.1 1.115 29 21.8 26.3
200 21.0 0.598 29 19.8 22.2
300 18.0 0.754 29 16.4 19.5
400 15.0 1.370 29 12.2 17.8
Isn't it possible to use variables in place of the actual predictor names in the at
argument of the emmeans
call?