pbreheny / visreg

Visualization of regression functions
http://pbreheny.github.io/visreg/
61 stars 18 forks source link

visreg fails to run depending on where regression data comes from #112

Closed travis-leith closed 11 months ago

travis-leith commented 11 months ago

seems to be related to #98 and #99. I think it would be neater to open a new issue with a minimal reproducible example:

library(mgcv)
library(visreg)

model <- gam(accel ~ s(times), data = MASS::mcycle)
visreg(model, "times") # fails with "Error in exists(as.character(CALL$data), call.env) : first argument has length > 1"

accel <- MASS::mcycle$accel
times <- MASS::mcycle$times
model <- gam(accel ~ s(times))
visreg(model, "times") #works

not sure if the title accurately reflects the problem so it might need to change as more information comes to light.

pbreheny commented 11 months ago

Thanks for pointing this out. The underlying issue is that visreg is designed to be object-oriented, but the data used to fit the model is not actually returned along with the fitted model object, so visreg has to hunt for it.

This should work now, though (version 2.7.0.5).