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:
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
bike_orderlines <- readRDS("bike_orderlines.rds")
bike_orderlines <- bike_orderlines %>%
mutate(Sales = price * quantity)
unique_categories <- bike_orderlines %>%
distinct(category_1) %>%
rename('Primary Category' = category_1)
unique_sub_categories <- bike_orderlines %>%
distinct(category_2) %>%
rename('Secondary Category' = category_2)
unique_frame_materials <- bike_orderlines %>%
distinct(frame_material) %>%
rename('Frame Material' = frame_material) %>%
View()
primary_category_sales <- bike_orderlines %>%
group_by(category_1) %>%
arrange(desc(sum(Sales))) %>%
rename('Primary Category' = category_1)
secondary_category_sales <- bike_orderlines %>%
group_by(category_2) %>%
arrange(desc(sum(Sales))) %>%
rename('Secondary Category' = category_2)
frame_material_sales <- bike_orderlines %>%
group_by(frame_material) %>%
arrange(desc(sum(Sales))) %>%
rename('Frame Material' = frame_material) %>%
View()
combinations <- bike_orderlines %>%
group_by(category_1, category_2) %>%
summarize(Aluminum = sum(Sales[frame_material == "Aluminum"]),
Carbon = sum(Sales[frame_material == "Carbon"]),
'Total Sales' = sum(Sales)) %>%
ungroup() %>%
rename('Primary Category' = category_1, 'Secondary Category' = category_2) %>%
View()
## `summarise()` has grouped output by 'category_1'. You can override using the
## `.groups` argument.
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.