Load required packages

install.packages(c(“tidyverse”,“lubridate”,“ggplot2”,“zoo”)) library(tidyverse) library(lubridate) library(ggplot2) library(zoo)

Load dataset

day <- read.csv(“day.csv”)

Convert date column to Date type

day\(dteday <- as.Date(day\)dteday, format=“%Y-%m-%d”)

Basic exploration

str(day) # Check data structure summary(day) # Summary statistics head(day) # First rows

Plot daily counts (cnt) over time

ggplot(day, aes(x=dteday, y=cnt)) + geom_line(color=“blue”) + labs(title=“Daily Bike Rentals Over Time”, x=“Date”, y=“Count”)

Plot casual vs registered users

ggplot(day, aes(x=dteday)) + geom_line(aes(y=casual, color=“Casual”)) + geom_line(aes(y=registered, color=“Registered”)) + labs(title=“Casual vs Registered Users”, y=“Count”) + scale_color_manual(values=c(“Casual”=“red”,“Registered”=“green”))

Smooth time series with rolling average (7-day)

day\(cnt_smooth <- rollmean(day\)cnt, k=7, fill=NA)

ggplot(day, aes(x=dteday)) + geom_line(aes(y=cnt), alpha=0.4) + geom_line(aes(y=cnt_smooth), color=“red”, size=1) + labs(title=“7-Day Rolling Average of Daily Rentals”, y=“Count”)