Set a default to display totals for an R session
pivot_default_totals(include_column_totals = TRUE, include_row_totals = TRUE)
include_column_totals | Indicates if the column totals are included in the pivot table |
---|---|
include_row_totals | Indicates if the row totals are included in the pivot table |
pivot_default_totals(TRUE, TRUE) retail_orders %>% pivot_rows(status, country) %>% pivot_values(n())#> n() #> Cancelled Spain 1 #> Sweden 1 #> UK 1 #> USA 1 #> Total 4 #> Disputed Australia 1 #> Denmark 1 #> Spain 1 #> Total 3 #> In Process Australia 1 #> Belgium 1 #> France 1 #> Spain 1 #> USA 2 #> Total 6 #> On Hold Sweden 1 #> USA 3 #> Total 4 #> Resolved Austria 1 #> Denmark 1 #> Spain 1 #> USA 1 #> Total 4 #> Shipped Australia 17 #> Austria 6 #> Belgium 6 #> Canada 7 #> Denmark 5 #> Finland 9 #> France 36 #> Germany 7 #> Ireland 2 #> Italy 8 #> Japan 6 #> Norway 9 #> Philippines 3 #> Singapore 9 #> Spain 32 #> Sweden 5 #> Switzerland 2 #> UK 12 #> USA 105 #> Total 286 #> Total 307