1

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

Community
  • 1
  • 1
iboboboru
  • 1,112
  • 2
  • 10
  • 21
  • I cannot reproduce with `dplyr` 0.5.0 and `data.table` 1.9.6, which are both currently on CRAN. – Axeman Oct 13 '16 at 11:17
  • 2
    Hi Axeman, I upgraded dplyr from 0.4.3 to 0.5.0 and resolves the issue. Going to close question. Thanks – iboboboru Oct 13 '16 at 11:28

1 Answers1

1

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

iboboboru
  • 1,112
  • 2
  • 10
  • 21
  • To close the question, you should mark this answer as "accepted", clicking the check mark on the left of it. – Frank Oct 13 '16 at 14:02