# Bike Shop Text Analysis
library(tidyverse)
library(lubridate)
# Read in Data
bike_orderlines_tbl <- read_rds("C:/Users/open/Documents/R PROJECTS/00_data/bike_sales/data_wrangled/bike_orderlines.rds")
bike_orderlines_tbl
bikes_tbl <- readxl::read_excel("C:/Users/open/Documents/R PROJECTS/00_data/bike_sales/data_raw/bikes.xlsx")
bikes_tbl
# Cleaning and Organizing Data into Usable Column Data
bikes_cleaned_tbl <- bikes_tbl %>%
select(model) %>%
mutate(model = case_when(
model == "CAAD Disc Ultegra" ~ "CAAD12 Disc Ultegra",
model == "Syapse Carbon Tiagra" ~ "Synapse Carbon Tiagra",
model == "Utegra" ~ "Supersix Evo Hi-Mod Utegra",
TRUE ~ model)) %>%
separate(col = model,
into = str_c("model_", 1:7),
sep = " ", remove = FALSE,
fill = "right",
extra = "drop") %>%
mutate(model_base = case_when(
str_detect(str_to_lower(model_1), "supersix") ~ str_c(model_1, model_2, sep = " "),
str_detect(str_to_lower(model_1), "fat") ~ str_c(model_1, model_2, sep = " "),
str_detect(str_to_lower(model_1), "beast") ~ str_c(model_1, model_2, model_3, model_4, sep = " "),
str_detect(str_to_lower(model_1), "bad") ~ str_c(model_1, model_2, sep = " "),
str_detect(str_to_lower(model_2), "29") ~ str_c(model_1, model_2, sep = " "),
TRUE ~ model_1)) %>%
mutate(model_tier = model %>%
str_replace(model_base, replacement = "") %>% str_trim()
) %>%
select(-matches("[0-9]")) %>%
mutate(
black = model_tier %>% str_to_lower() %>% str_detect("black") %>% as.numeric(),
hi_mod = model_tier %>% str_to_lower() %>% str_detect("hi_mod") %>% as.numeric(),
team = model_tier %>% str_to_lower() %>% str_detect("team") %>% as.numeric(),
red = model_tier %>% str_to_lower() %>% str_detect("red") %>% as.numeric(),
ultegra = model_tier %>% str_to_lower() %>% str_detect("ultegra") %>% as.numeric(),
dura_ace = model_tier %>% str_to_lower() %>% str_detect("dura ace") %>% as.numeric(),
disc = model_tier %>% str_to_lower() %>% str_detect("disc") %>% as.numeric()
)
View(bikes_cleaned_tbl)