I use data.table and dplyr together. I recently noticed that dplyr :: group_by can also set a key in a data.table object.
library(data.table)
library(dplyr)
dt <- data.table(A=rep(c("a", "b"), times=c(2, 3)), B = rep(1, 5))
tables()
group_by(dt, A)
tables()
I wonder why this is happening. Is this intended? as I know, Hadley is trying to make dplyr compatible with data.table.
(If possible, I would also like to know how the key is implemented in data.table. It is very interesting why setkey can change it in place?)
thank
At the request of G. Grothendieck:
library(data.table)
dt <- data.table(A = rep(c("a", "b"), times=c(2, 3)),
B = rep(1, 5))
dplyr::group_by(dt, A)
tables()
I use these two packages quite often, I would like to know all the details in order to avoid errors.
source
share