当我broom:::glance
以以下方式使用时:
library(dplyr)
library(broom)
mtcars %>% do(model = lm(mpg ~ wt, .)) %>% glance(model)
我明白了
Error in complete.cases(x) : invalid 'type' (list) of argument
但是,当我添加一个group_by
:
mtcars %>% group_by(am) %>% do(model = lm(mpg ~ wt, .)) %>% glance(model)
确实给出了预期的结果:
Source: local data frame [2 x 12]
Groups: am
am r.squared adj.r.squared sigma statistic p.value df logLik AIC BIC deviance df.residual
1 0 0.589 0.565 2.53 24.4 1.25e-04 2 -43.5 93.1 95.9 108.7 17
2 1 0.826 0.810 2.69 52.3 1.69e-05 2 -30.2 66.4 68.1 79.3 11
我在这里遗漏了什么,还是 dplyr/broom 中的错误?