R Markdown

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

Including Plots

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. C:/Users/Richard/Documents/FINANCIAL DATABASE/bike_orderlines.rds # Load necessary libraries library(dplyr)

Load the data

bike_orderlines <- readRDS(“C:/Users/Richard/Documents/FINANCIAL DATABASE/bike_orderlines.rds”)

Inspect the data structure

str(bike_orderlines)

Check for columns like customer name/ID and product category (e.g., bike type)

Assuming the relevant columns are ‘customer_name’, ‘bike_type’, and ‘sales’

Aggregate sales by customer and bike type

customer_preferences <- bike_orderlines %>% group_by(customer_name, bike_type) %>% # Replace ‘customer_name’ and ‘bike_type’ with actual column names summarise(total_sales = sum(sales, na.rm = TRUE), # Replace ‘sales’ with actual sales column name purchase_count = n()) %>% arrange(desc(total_sales))

Find the top 3 customers for road bikes

top_road_customers <- customer_preferences %>% filter(bike_type == “Road”) %>% # Replace with the exact value for road bikes in your dataset slice_max(total_sales, n = 3)

Find the top 3 customers for mountain bikes

top_mountain_customers <- customer_preferences %>% filter(bike_type == “Mountain”) %>% # Replace with the exact value for mountain bikes in your dataset slice_max(total_sales, n = 3)

Display the results

print(“Top 3 customers for road bikes:”) print(top_road_customers)

print(“Top 3 customers for mountain bikes:”) print(top_mountain_customers)