You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, if a by is specified then the column names are simply repeated rather than prepended with the function names. It would seem preferable to keep prepending the names regardless of whether there is a by.
> dt[, c(mean = lapply(.SD, mean), median = lapply(.SD, median)), .SDcols = c("mpg", "cyl"), by = "am"]
am mpg cyl mpg cyl
1: 1 24.39231 5.076923 22.8 4
2: 0 17.14737 6.947368 17.3 8
> sessionInfo()
R version 4.1.1 (2021-08-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] data.table_1.14.2
The text was updated successfully, but these errors were encountered:
When aggregating, if no by is specified then the output columns have the function names prepended ("mean", "median"). This is helpful.
However, if a by is specified then the column names are simply repeated rather than prepended with the function names. It would seem preferable to keep prepending the names regardless of whether there is a by.
The text was updated successfully, but these errors were encountered: