Although fit
is a list, it has class glm
, so auto-printing it dispatches the print.glm()
print method. As shown below, as.list()
preserves the object's class, so doesn't help you at all.
fit <- glm(speed~dist, data=cars) ## A silly example
class(fit)
# [1] "glm" "lm"
class(as.list(fit))
# [1] "glm" "lm"
exists("print.glm")
# [1] TRUE
Either of the following will print fit
as a list.
unclass(fit) ## Returns and immediately auto-prints object of class "list"
## using print.default()
print.default(fit) ## Bypasses method dispatch, directly calling desired print
## method