Following on from post: Fitting several regression models with dplyr
I came across a problem when attempting to apply this with a data.table . The problem does not exist when the data is a data.frame
Example:
library(data.table)
library(dplyr)
mtcarsDT <- data.table(mtcars)
lmGroups <- mtcarsDT %>%
group_by(cyl) %>%
do(mod = lm(mpg ~ disp, data = .))
Extract coefficients of the models
lmGroups %>%
do(data.frame(var = names(coef(.$mod)),
coef = coef(.$mod)))
Error in do_.tbl_dt(.data, .dots = lazyeval::lazy_dots(...)) : argument ".f" is missing, with no default
library(broom)
lmGroups %>% tidy(mod)
Error in psych::describe(x, ...) : object 'mod' not found