Drill into a hierarchy dimension

pivot_drill(.data, ...)

Arguments

.data

A data.frame or a pivot_prep object

...

Variable or variables to drill by

Examples

retail_orders %>% pivot_rows(order_date = dim_hierarchy( year = as.integer(format(orderdate, "%Y")), month = as.integer(format(orderdate, "%m")) )) %>% pivot_values(sum(sales)) %>% pivot_drill(order_date)
#> sum(sales) #> 2003 1 129753.6 #> 2 140836.19 #> 3 174504.9 #> 4 201609.55 #> 5 192673.11 #> 6 168082.56 #> 7 187731.88 #> 8 197809.3 #> 9 263973.36 #> 10 568290.97 #> 11 1029837.66 #> 12 261876.46 #> Total 3516979.54 #> 2004 1 316577.42 #> 2 311419.53 #> 3 205733.73 #> 4 206148.12 #> 5 273438.39 #> 6 286674.22 #> 7 327144.09 #> 8 461501.27 #> 9 320750.91 #> 10 552924.25 #> 11 1089048.01 #> 12 372802.66 #> Total 4724162.6 #> 2005 1 339543.42 #> 2 358186.18 #> 3 374262.76 #> 4 261633.29 #> 5 457861.06 #> Total 1791486.71 #> Total 10032628.85