tidyverts / tidyverts/fabletools

aggregate_key() produces aggregations of single leaf nodes

Open
#226 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
98
Forks
37
PR merge metrics
No merged PRs in 30d

Description

This is not necessarily a bug, just something to be aware of. An option to produce unbalanced hierarchies for redundant aggregations may be useful.

library(fabletools)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
tsibble::tourism %>% 
  aggregate_key(Purpose * (State / Region), Trips = sum(Trips)) %>% 
  filter(Purpose == "Business", State == "ACT")
#> # A tsibble: 160 x 5 [1Q]
#> # Key:       Purpose, State, Region [2]
#>    Quarter Purpose  State Region       Trips
#>      <qtr> <chr>    <chr> <chr>        <dbl>
#>  1 1998 Q1 Business ACT   <aggregated> 150. 
#>  2 1998 Q2 Business ACT   <aggregated>  99.9
#>  3 1998 Q3 Business ACT   <aggregated> 130. 
#>  4 1998 Q4 Business ACT   <aggregated> 102. 
#>  5 1999 Q1 Business ACT   <aggregated>  95.5
#>  6 1999 Q2 Business ACT   <aggregated> 229. 
#>  7 1999 Q3 Business ACT   <aggregated> 109. 
#>  8 1999 Q4 Business ACT   <aggregated> 159. 
#>  9 2000 Q1 Business ACT   <aggregated> 105. 
#> 10 2000 Q2 Business ACT   <aggregated> 202. 
#> # … with 150 more rows

Created on 2020-06-19 by the reprex package (v0.3.0)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the R example using tsibble::tourism and aggregate_key(Purpose * (State / Region), Trips = sum(Trips)) to reproduce the single-leaf aggregation. Read the aggregate_key() entry point and clarify the desired option and expected unbalanced hierarchy before defining what a complete change would look like.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.