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’.
bike_orderline_table <- readRDS("C:\\Users\\emman\\Downloads\\bike_orderlines.rds")
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
result <- bike_orderline_table %>%
group_by(`Prime category` = category_1, `Secondary category` = category_2, `Frame Material` = frame_material) %>%
summarise(Sales = sum(total_price)) %>%
mutate(Sales = paste0("$ ", format(Sales, big.mark = ",")))
## `summarise()` has grouped output by 'Prime category', 'Secondary category'. You
## can override using the `.groups` argument.
print(result)
## # 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
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.