Case Study
Case Study
Create an R-based case study by using R code to analyze the Online Retail Dataset using a sample
dataset includes fields such as InvoiceNo, StockCode, Description, Quantity, InvoiceDate,
UnitPrice, CustomerID, and Country.
R-Code:
Step 1: Objective
The Online Retail Dataset contains information about online transactions, including invoice details,
product information, customer IDs, and country of origin. We'll use R to analyze this data and gain
insights into customer behavior, product sales, and revenue.
Step 2: Dataset
Step 3: R-Code
install.packages("ggplot2")
library(ggplot2)
install.packages("dplyr")
library(dplyr)
install.packages("lubridate")
library(lubridate)
# Load the dataset
library(readr)
retail_data <- read_csv("C:/Users/DELL/Desktop/online_retail.csv")
View(retail_data)
summary(retail_data)
#Missing Value
Mean_Quantity = mean(retail_data$Quantity,na.rm =TRUE)
Mean_Quantity
retail_data$Quantity=ifelse(is.na(retail_data$Quantity ), Mean_Quantity , retail_data$Quantity)
retail_data$Quantity
#OR
# Load ggplot2
library(ggplot2)
ggplot(top_products, aes(x = reorder(Description, TotalRevenue), y = TotalRevenue)) +
geom_col() +
xlab("Product") +
ylab("Revenue") +
ggtitle("Top 10 Products by Revenue")
Reorders the product names based on revenue so that bars appear in ascending/descending order.
# Revenue by country
Reorders the product names based on revenue so that bars appear in ascending/descending order.
#Descriptive Statistics
Summary(retail_data$UnitPrice)
Summary(retail_data$Revenue)
#Testing of Hypothesis
#Null Hypothesis (H0): (μ1 = μ2) i.e.There is no significant difference in Revenue of United Kingdom
and Australia.
#Alternative Hypothesis (H1) :(μ1 ≠ μ2)i.e. There is a significant difference in Revenue of United
Kingdom and Australia.
# 2) ANOVA
#H0: Revenue do not vary significantly across different countries.
#H1: Revenue vary significantly across different countries.
# Perform ANOVA
anova_result <- aov(Revenue ~ Country, data = retail_data)
anova_result
summary(anova_result)