Which product categories have the most sales?
- Use ‘bike_orderline_tbl’.
- Group and summarize the data calling the new column as ‘Sales’.
- Format the sales as ‘dollars()’.
- Rename ‘category_1’ to ‘Prime category’, ‘category_2’ to ‘Secondary
category’, ‘frame_material’ to ‘Frame Material’.
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(scales)
bike_orderline_tbl <- read.csv("bike folder/bike_orderlines.csv")
bike_orderline_tbl %>%
group_by(category_1, category_2, frame_material) %>%
summarize(Sales = sum(total_price)) %>%
mutate(Sales = scales::dollar(Sales)) %>%
rename("Prime category" = category_1, "Secondary category" = category_2,
"Frame Material" = frame_material)
## `summarise()` has grouped output by 'category_1', 'category_2'. You can
## override using the `.groups` argument.
## # A tibble: 13 × 4
## # Groups: Prime category, Secondary category [9]
## `Prime category` `Secondary category` `Frame Material` Sales
## <chr> <chr> <chr> <chr>
## 1 Mountain Cross Country Race Aluminum $3,318,560
## 2 Mountain Cross Country Race Carbon $15,906,070
## 3 Mountain Fat Bike Aluminum $1,052,620
## 4 Mountain Over Mountain Carbon $7,571,270
## 5 Mountain Sport Aluminum $1,932,755
## 6 Mountain Trail Aluminum $4,537,610
## 7 Mountain Trail Carbon $4,835,850
## 8 Road Cyclocross Carbon $2,108,120
## 9 Road Elite Road Aluminum $5,637,795
## 10 Road Elite Road Carbon $9,696,870
## 11 Road Endurance Road Aluminum $1,612,450
## 12 Road Endurance Road Carbon $8,768,610
## 13 Road Triathalon Carbon $4,053,750