````markdown
library(readxl)
Superstore <- read_excel("Superstore_clean.xlsx")
With growing demands and cut-throat competitions in the market, a Superstore
Giant is seeking your knowledge in understanding what works best for them.
They would like to understand which products, regions, categories and customer
segments they should target or avoid. You can even take this a step further
and try and build a Regression model to predict Sales or Profit. Go crazy with
the dataset, but also make sure to provide some business insights to improve.
- **Row ID** – Unique ID for each row
- **Order ID** – Unique Order ID for each Customer
- **Order Date** – Order Date of the product
- **Ship Date** – Shipping Date of the Product
- **Ship Mode** – Shipping Mode specified by the Customer
- **Customer ID** – Unique ID to identify each Customer
- **Customer Name** – Name of the Customer
- **Segment** – The segment where the Customer belongs
- **Country** – Country of residence of the Customer
- **City** – City of residence of the Customer
- **State** – State of residence of the Customer
- **Postal Code** – Postal Code of every Customer
- **Region** – Region where the Customer belong
- **Product ID** – Unique ID of the Product
- **Category** – Category of the product ordered
- **Sub-Category** – Sub-Category of the product ordered
- **Product Name** – Name of the Product
- **Sales** – Sales of the Product
- **Quantity** – Quantity of the Product
- **Discount** – Discount provided
- **Profit** – Profit/Loss incurred
library(dplyr)
Superstore_Tech <- Superstore %>%
filter(Category == "Technology")
library(dplyr)
library(lubridate)
Superstore_Tech <- Superstore %>%
filter(Category == "Technology") %>%
mutate(year = year(Order_Date), month = month(Order_Date, label = TRUE, abbr = TRUE))
# 'year' võetakse Order_Date kuupäevast (nt 2014, 2015)
# 'month' võetakse Order_Date kuupäevast ja pannakse lühendatud kuunimi ('abbr')
# 'label = TRUE' teeb kuu numbrist kuunime
monthly_tech <- Superstore_Tech %>%
group_by(year, month) %>%
summarise(total_sales = sum(Sales))
# Lisame uue veeru 'year' tellimuse aastaga, rühmitame read aasta ja kuu järgi
# ning liidame igal aastal iga kuu kõik tehnoloogia kategooria müügid kokku.
avg_monthly_sales <- mean(monthly_tech$total_sales)
library(ggplot2)
library(scales)
ggplot(monthly_tech, aes(x = month, y = total_sales)) +
geom_line(aes(color = factor(year), group = year)) +
geom_point(aes(color = factor(year), group = year)) +
geom_hline(aes(yintercept = avg_monthly_sales, linetype = "Keskmine"), color = "red") +
annotate("text", x = Inf, y = avg_monthly_sales,
label = comma(avg_monthly_sales, accuracy = 1,
big.mark = " "),
hjust = 1.05, vjust = -0.3, color = "red", size = 3) +
scale_color_brewer(palette = "Dark2", name = "Aasta") +
scale_linetype_manual(values = c("Keskmine" = "dashed"), name = "") +
scale_y_continuous(labels = label_comma(big.mark = " ")) +
labs(title = "Tehnoloogia kategooria igakuine müügitulu aastatel 2014–2017", x = "Kuu",
y = "Müügitulu") +
theme_classic()
# geom_line joonistab aastate müügijooned
# geom_point lisab punktid igale kuumüügile
# geom_hline lisab punase keskmise horisontaalse joone legendiga
# annotate("text", ...) kirjutab keskmise numbri joone paremasse serva
# scale_color_brewer seab aastate värvid (Dark2 palett).
# scale_linetype_manual lisab legendi keskmisele joonele (katkendlik joon).
# scale_y_continuous vormindab Y-telje tühikutega (nt “60 000”).
# labs seab pealkirja ja telgede nimed.
# theme_classic() kasutab puhast klassikalist kujundust.
Müük on hooajaline, sest aasta alguses ja suvekuudel jääb müügitulu madalamaks,
kuid märtsis, sügiskuudel ja detsembris on see kõrgem. 2017. aasta kuine müügitulu ulatub kõige kõrgemale.
Märtsis võib müügitulu tõusta, sest see kuulub jaekaubanduses kevadiste
sooduspakkumiste perioodi, mida mõjutavad lihavõtted, kevadhooaja algus ja
sellega seotud ostukäitumine; samal ajal on jaanuar ja veebruar tavaliselt
pühadejärgne aeglustumine, mil müügitulu ongi madalam, ning juuli–august
võivad olla mõjutatud jaekaubanduse suvisest langusperioodist, kus tarbijad
suunavad kulutusi rohkem puhkusereisidele kui ostudele.(viide 1)
Ettevõte peaks ära kasutama märtsi ja sügiskuude loomulikku hooajalist
ostuaktiivsust (kevadised sooduspakkumised, back-to-school, aasta lõpu
ettevalmistus). Väljakutseks on sõltuvus üksikutest tippkuudest, mistõttu
tasub tugevamalt toetada perioode (nt turunduse abil), mida jaekaubanduses
iseloomustavad pühadejärgne aeglustumine ja suvine langusperiood, et
müügitulu aastaringselt ühtlustada. (viide 1)
# 1. Confiz (2025). *What are the best and worst months for retail sales? *
# https://www.confiz.com/blog/best-and-worst-months-for-retail-sales/