library(dplyr) library(lubridate) library(readr)
bike_sales <- readRDS(“C:/Users/Richard/Documents/FINANCIAL DATABASE/bike_orderlines.rds”)
str(bike_sales) head(bike_sales)
bike_sales <- bike_sales %>% mutate(month = month(date, label = TRUE), year = year(date))
monthly_sales <- bike_sales %>% group_by(year, month) %>% summarise(total_sales = sum(sales_column_name, na.rm = TRUE)) # Replace with actual sales column name
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)
etf_data <- read_csv(“path/to/your/MidtermDataTEJ.csv”) # Replace with actual file path
str(etf_data) head(etf_data)
etf_data <- etf_data %>% mutate(date = ymd(date)) # Use appropriate date format if not YYYY-MM-DD
etf_filtered <- etf_data %>% filter(ETF_name %in% c(“ETF0050”, “ETF0052”, “ETF0056”))
yearly_avg_prices <- etf_filtered %>% group_by(ETF_name, year = year(date)) %>% summarise(avg_closing_price = mean(closing_price, na.rm = TRUE))
print(“Yearly average closing prices for ETFs 0050, 0052, and 0056:”) print(yearly_avg_prices) or