library(tidyverse) library(lubridate) library(dplyr)
##1 bike_orderlines <- readRDS(“./bike_orderlines.rds”)
bike_rename <- bike_orderlines %>% mutate(model = case_when( model == “CAAD Disc Ultegra” ~“CAAD12 Disc Ultegra”, TRUE ~ model))
bike_rename <-bike_rename %>% mutate(model = case_when( model == “Syapse Carbon Tiagra” ~“Synapse Carbon Tiagra”, TRUE ~ model))
bike_rename <- bike_rename %>% mutate(model = case_when( model == “Supersix Evo Hi-Mod Utegra” ~“Supersix Evo Hi-Mod Ultegra”, TRUE ~ model))
glimpse(bike_rename)
##2 bike_sales_tbl <- bike_rename %>% select(order_date, total_price) %>% mutate(order_date = ymd(order_date)) %>% mutate(Month = month(order_date, label = TRUE)) %>% group_by(Month) %>% summarize(Sales = sum(total_price)) %>% mutate(Sales = scales::dollar(Sales))
bike_sales_tbl %>% View()
bike_blackInc <- bike_rename %>% mutate(BlackInc = str_detect(model, “Black Inc”)) %>% group_by(BlackInc) %>% summarize(MeanOrderline = mean(total_price)) %>% mutate(MeanOrderline = scales::dollar(MeanOrderline))
bike_blackInc #There is a huge spread between the median of the products that contain the ‘Black Inc’ attribute, with it having a higher median.
bike_ultegra <- bike_rename %>% mutate(Ultegra = str_detect(model, “Ultegra”)) %>% group_by(Ultegra) %>% summarize(MeanOrderline = mean(total_price)) %>% mutate(MeanOrderline = scales::dollar(MeanOrderline))
bike_ultegra #Items with the ‘Ultegra’ feature tend to have a slightly lower median that the remaining items. ## Median sales by ‘Disc’ attribute bike_disc <- bike_rename %>% mutate(Disc = str_detect(model, “Disc”)) %>% group_by(Disc) %>% summarize(MeanOrderline = mean(total_price)) %>% mutate(MeanOrderline = scales::dollar(MeanOrderline))
bike_disc # Items containing the ‘Disc’ attribute have almost the same median as those that don’t.
bike_rename %>% select(category_1, category_2, model, total_price) %>% mutate(Model_Base = str_extract(model, “1+”)) %>% group_by(category_1, category_2, Model_Base) %>% summarize( Mean_Price = scales::dollar(mean(total_price)), Max_Price = scales::dollar(max(total_price)), Min_Price = scales::dollar(min(total_price)) ) %>% View() #This data display shows that having a high max price doesn’t necessarly translate to a high min, due to the spread of having very low prices in between models.
a-zA-Z\s-↩︎