Skip to content

Instantly share code, notes, and snippets.

@watermouth
Created August 7, 2019 04:45
Show Gist options
  • Select an option

  • Save watermouth/a572b41bcc1746441fad365edaef6822 to your computer and use it in GitHub Desktop.

Select an option

Save watermouth/a572b41bcc1746441fad365edaef6822 to your computer and use it in GitHub Desktop.
dplyr: summarise_at not working on data.table

error message

data.table(iris) %>% group_by(Species) %>% summarise_at(vars(starts_with("Sepal")), funs(sum))
Error in !funs : invalid argument type

workaround

convert the data type data.table to data.frame.

> data.frame(iris) %>% group_by(Species) %>% summarise_at(vars(starts_with("Sepal")), funs(sum))
# A tibble: 3 x 3
  Species    Sepal.Length Sepal.Width
  <fct>             <dbl>       <dbl>
1 setosa             250.        171.
2 versicolor         297.        138.
3 virginica          329.        149.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment