1
votes

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

1
I cannot reproduce with dplyr 0.5.0 and data.table 1.9.6, which are both currently on CRAN. - Axeman
Hi Axeman, I upgraded dplyr from 0.4.3 to 0.5.0 and resolves the issue. Going to close question. Thanks - iboboboru

1 Answers

1
votes

I upgraded dplyr from 0.4.3 to 0.5.0 and resolves the issue. Going to close question. Thanks