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
library(tidyr)
library(stringr)
library(scales)
library(readxl)
bike_orderlines <- read_excel("./bike_orderlines.xlsx")
bike_orderlines %>%
  group_by(category_1, category_2, frame_material) %>% 
  summarise(sales=sum(total_price)) %>%
  ungroup() %>% 
  rename(
    `Prime category` = category_1, 
    `Secondary category` = category_2, 
    `Frame Material` = frame_material) %>% 
  mutate(Sales = dollar(sales)
         )
## `summarise()` has grouped output by 'category_1', 'category_2'. You can
## override using the `.groups` argument.
## # A tibble: 13 × 5
##    `Prime category` `Secondary category` `Frame Material`    sales Sales      
##    <chr>            <chr>                <chr>               <dbl> <chr>      
##  1 Mountain         Cross Country Race   Aluminum          3318560 $3,318,560 
##  2 Mountain         Cross Country Race   Carbon           15906070 $15,906,070
##  3 Mountain         Fat Bike             Aluminum          1052620 $1,052,620 
##  4 Mountain         Over Mountain        Carbon            7571270 $7,571,270 
##  5 Mountain         Sport                Aluminum          1932755 $1,932,755 
##  6 Mountain         Trail                Aluminum          4537610 $4,537,610 
##  7 Mountain         Trail                Carbon            4835850 $4,835,850 
##  8 Road             Cyclocross           Carbon            2108120 $2,108,120 
##  9 Road             Elite Road           Aluminum          5637795 $5,637,795 
## 10 Road             Elite Road           Carbon            9696870 $9,696,870 
## 11 Road             Endurance Road       Aluminum          1612450 $1,612,450 
## 12 Road             Endurance Road       Carbon            8768610 $8,768,610 
## 13 Road             Triathalon           Carbon            4053750 $4,053,750