Switch the columns with the rows on a pivot table
pivot_flip(.data)
.data | A pivot_table object |
---|
retail_orders %>% pivot_rows(status) %>% pivot_columns(country) %>% pivot_values(n()) %>% pivot_flip()#> Cancelled Disputed In Process On Hold Resolved Shipped Total #> Australia 1 1 17 19 #> Austria 1 6 7 #> Belgium 1 6 7 #> Canada 7 7 #> Denmark 1 1 5 7 #> Finland 9 9 #> France 1 36 37 #> Germany 7 7 #> Ireland 2 2 #> Italy 8 8 #> Japan 6 6 #> Norway 9 9 #> Philippines 3 3 #> Singapore 9 9 #> Spain 1 1 1 1 32 36 #> Sweden 1 1 5 7 #> Switzerland 2 2 #> UK 1 12 13 #> USA 1 2 3 1 105 112 #> Total 4 3 6 4 4 286 307