Load necessary libraries

library(dplyr) library(lubridate) library(readr)

1. Load the bike sales data

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

2. Check the structure of the data to understand its contents

str(bike_sales) head(bike_sales)

3. Extract the month and year from the date column

Assuming there’s a ‘date’ column; replace with actual date column name if different

bike_sales <- bike_sales %>% mutate(month = month(date, label = TRUE), year = year(date))

4. Calculate monthly sales

monthly_sales <- bike_sales %>% group_by(year, month) %>% summarise(total_sales = sum(sales_column_name, na.rm = TRUE)) # Replace with actual sales column name

5. Find the month with the highest sales

highest_sales <- monthly_sales %>% group_by(month) %>% summarise(average_sales = mean(total_sales)) %>% arrange(desc(average_sales))

print(“Month with highest average sales:”) print(highest_sales)

Interpretation for marketing:

If highest_sales shows a specific peak month, this month is ideal for marketing efforts.

Load the ETF data from the CSV file

etf_data <- read_csv(“path/to/your/MidtermDataTEJ.csv”) # Replace with actual file path

Inspect the data structure and first few rows to understand the columns

str(etf_data) head(etf_data)

Assuming columns for ‘date’, ‘closing_price’, and ‘ETF_name’ (adjust as per your actual column names)

Convert the date column to Date format if it’s not already

etf_data <- etf_data %>% mutate(date = ymd(date)) # Use appropriate date format if not YYYY-MM-DD

Filter data for ETFs 0050, 0052, and 0056

etf_filtered <- etf_data %>% filter(ETF_name %in% c(“ETF0050”, “ETF0052”, “ETF0056”))

Calculate yearly average closing prices for each ETF

yearly_avg_prices <- etf_filtered %>% group_by(ETF_name, year = year(date)) %>% summarise(avg_closing_price = mean(closing_price, na.rm = TRUE))

Display the results

print(“Yearly average closing prices for ETFs 0050, 0052, and 0056:”) print(yearly_avg_prices) or