Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rollups #274

Closed
ggrothendieck opened this issue Apr 23, 2024 · 1 comment
Closed

rollups #274

ggrothendieck opened this issue Apr 23, 2024 · 1 comment

Comments

@ggrothendieck
Copy link

Suggest supporting rollups. For example, here is a rollup using R.

# input data
dat <- data.frame(
   year = rep(2000:2001, each = 5L),
   month = rep(rep(1:2, 2), rep(2:3, 2)),
   value = c(34L, 42L, 18L, 22L, 6L, 3L, 2L, 8L, 2L, 9L),
   n = 1:10
)
dat
##    year month value  n
## 1  2000     1    34  1
## 2  2000     1    42  2
## 3  2000     2    18  3
## 4  2000     2    22  4
## 5  2000     2     6  5
## 6  2001     1     3  6
## 7  2001     1     2  7
## 8  2001     2     8  8
## 9  2001     2     2  9
## 10 2001     2     9 10

# compute rollup
library(reshape2)
m <- melt(dat, measure.vars = "value")
dcast(m, year + month + n ~ variable, fun.aggregate = sum, margins = TRUE)
##     year month     n value (all)
## 1   2000     1     1    34    34
## 2   2000     1     2    42    42
## 3   2000     1 (all)    76    76
## 4   2000     2     3    18    18
## 5   2000     2     4    22    22
## 6   2000     2     5     6     6
## 7   2000     2 (all)    46    46
## 8   2000 (all) (all)   122   122
## 9   2001     1     6     3     3
## 10  2001     1     7     2     2
## 11  2001     1 (all)     5     5
## 12  2001     2     8     8     8
## 13  2001     2     9     2     2
## 14  2001     2    10     9     9
## 15  2001     2 (all)    19    19
## 16  2001 (all) (all)    24    24
## 17 (all) (all) (all)   146   146
@shenwei356
Copy link
Owner

Sorry, no plan for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants