Using "at" with factors breaks check for extrapolated values
Closed this issue · 0 comments
nathanielolin commented
rm(list = ls())
data(mtcars)
mtcars$brand <- as.factor(gsub(' .*', '', row.names(mtcars)))
ols <- glm(mpg ~ cyl + disp + brand, data = mtcars)
# Works
modmarg::marg(ols, var_interest = 'cyl')
# Works, warns about extrapolated values
modmarg::marg(ols, var_interest = 'cyl', at = list(disp = 30))
# Doesn't work
modmarg::marg(ols, var_interest = 'cyl', at = list(brand = 'Toyota'))
Problem is here: https://github.com/anniejw6/modmarg/blob/master/R/marg.R#L133-L139 logic needs to only check for min/max after determining the variable is numeric, not in the same statement.