Skip to content

Feature-Request: Allow env argument in groupingsets #6921

@iagogv3

Description

@iagogv3

Would be implementable a special by aggregating on full data and by groups? I mean.

> library(data.table)
data.table 1.17.0 using 6 threads (see ?getDTthreads).  Latest news: r-datatable.com
> input <- if (file.exists("flights14.csv")) {
+    "flights14.csv"
+ } else {
+   "https://raw.githubusercontent.com/Rdatatable/data.table/master/vignettes/flights14.csv"
+ }
> flights <- fread(input)
trying URL 'https://raw.githubusercontent.com/Rdatatable/data.table/master/vignettes/flights14.csv'
Content type 'text/plain; charset=utf-8' length 9587529 bytes (9.1 MB)
downloaded 9.1 MB

> ans <- flights[, .(.N), by = .(origin)]
> ans
   origin     N
   <char> <int>
1:    JFK 81483
2:    LGA 84433
3:    EWR 87400
> rbind(cbind(flights[, .(.N)], origin = NA), ans)[,c(2,1)]
   origin      N
   <char>  <int>
1:   <NA> 253316
2:    JFK  81483
3:    LGA  84433
4:    EWR  87400

being the last, the output of, let's say, flights[, .(.N), sby = origin]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions