A

Load necessary libraries

library(ggplot2) library(scales) library(dplyr) library(lubridate)

Load the data

data <- read.csv(“~/TCD Study/Data Mining/SouvenirSales.csv”)

Convert Date column to Date format and then to quarters

data\(Date <- as.Date(paste0("01-", data\)Date), format = “%d-%b-%y”) data\(Quarter <- paste0(year(data\)Date), “-Q”, quarter(data$Date))

Aggregate the sales by quarter

quarterly_data <- data %>% group_by(Quarter) %>% summarize(Sales = sum(Sales))

Plot the time plot data

ggplot(quarterly_data, aes(x = Quarter, y = Sales, group = 1)) + geom_line() + ggtitle(“Quarterly Sales Plot”) + xlab(“Quarter”) + ylab(“Sales”) + theme(axis.text.x = element_text(angle = 45, hjust = 1))

B

Change the scale on the x-axis, or on the y-axis, or on both to log-scale in order

to achieve a linear relationship. Select the time plot that seems most linear.

Plot the time plot data with log scale on y-axis

ggplot(quarterly_data, aes(x = Quarter, y = Sales, group = 1)) + geom_line() + ggtitle(“Quarterly Sales Plot (Log Scale)”) + xlab(“Quarter”) + ylab(“Sales”) + scale_y_log10() + theme(axis.text.x = element_text(angle = 45, hjust = 1))