Database Reference
In-Depth Information
Then, we'll use $rollup to get the statistics for groups of data:
user=> (i/$rollup :mean :POP100 :STATE census)
| :STATE | :POP100 |
|--------+---------------|
| 34 | 1054049/109 |
| 6 | 35184222/1523 |
| 18 | 4413508/681 |
| 5 | 1941247/541 |
user=> (i/$rollup s/sd :POP100 :STATE census)
| :STATE | :POP100 |
|--------+---------------|
| 34 | 1054049/109 |
| 6 | 35184222/1523 |
| 18 | 4413508/681 |
| 5 | 1941247/541 |||
How it works…
The $rollup function takes the dataset (the fourth parameter) and groups the rows by the
values of the grouping ield (the third parameter). It takes the group subsets of the data and
extracts the values from the ield to aggregate (the second parameter). It passes those values
to the aggregate function (the irst parameter) to get the inal table of values. That's a lot for
one small function. Here's a snapshot to make it clearer:
 
Search WWH ::




Custom Search