0% found this document useful (0 votes)
9 views12 pages

DAR CASE STUDY

The document outlines a case study for analyzing customer data for the e-commerce platform 'ShopEase' using R. It includes details about the dataset structure, objectives for analysis, and step-by-step instructions for creating a CSV file, loading it into R, and performing various analyses. Key tasks include checking data structure, summarizing data, identifying missing values, and calculating average purchase amounts.

Uploaded by

sharmahemant3610
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views12 pages

DAR CASE STUDY

The document outlines a case study for analyzing customer data for the e-commerce platform 'ShopEase' using R. It includes details about the dataset structure, objectives for analysis, and step-by-step instructions for creating a CSV file, loading it into R, and performing various analyses. Key tasks include checking data structure, summarizing data, identifying missing values, and calculating average purchase amounts.

Uploaded by

sharmahemant3610
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Case Study: Analyzing Customer Data for an E-

Commerce Platform using R

Compiled and Presented by:


Dr.Chetna Arora
Scenario

You have been hired by an e-commerce platform,
"ShopEase," which is experiencing rapid growth.
The company wants to understand its customer
demographics, purchasing habits, and how certain
factors are influencing sales. Your task is to explore
the customer dataset, which contains information
about customers, their purchases, and the
platform's product categories.
The dataset has the following columns:

1) Customer ID – Unique ID for each customer


2)Age – Age of the customer
3)Gender – Gender of the customer (Male/Female)
4)Annual Income – The yearly income of the
customer
5) Product Category – The category of products the
customer purchased (Electronics, Clothing, Home
Decor, etc.)
6) Purchase Amount – The total amount spent by the
customer in a particular transaction
Objective:
• You will analyze this dataset using R to identify
patterns and gain insights about customers.
• This will include loading the dataset, checking
its structure, identifying missing values,
summarizing the data, and answering specific
business-related questions.
Customer ID Age Gender Annual Product Purchase
Income Category Amount

1 25 Male 40000 Electronics 200

2 34 Female 52000 Clothing 150

3 28 Female NA Home decor 80

4 NA Male 48000 Electronics 300

5 42 Female 75000 Clothing 500

5 29 Male 62000 Home decor NA


• Step 1: Create the CSV File
First, we need to create a CSV file with the provided dataset
for "ShopEase" customers.

Steps to Create the CSV File:


Open Microsoft Excel, Google Sheets, or any text editor (like
Notepad).
Enter the data as shown above, including the header
(Customer ID, Age, Gender, Annual Income, Product
Category, Purchase Amount).
Save the file as customer_data.csv in a directory of your
choice.
• Step 2: Load the CSV File in R
Now that the CSV file is created, students can load it into R and
begin working with it.

Steps to Load the CSV File in R:


Set the Working Directory: Make sure R is pointing to the
directory where the customer_data.csv file is saved. You can do
this by using the setwd() function. Replace
"path_to_your_directory" with the actual path.

setwd("C:/path_to_your_directory")
Read the CSV File: Use the read.csv() function to load the file into
R.

customer_data <- read.csv("customer_data.csv")


View the Data: Check if the
data has been loaded
correctly.

# Display the data


print(customer_data)
• Step 3: Perform Analysis
Once the dataset is loaded, students can perform
a series of tasks to analyze the customer data.

1. Check the Structure of the Data:


str(customer_data)
This will show the structure of the dataset,
including the data types for each column.
• 2. Summarize the Data:

summary(customer_data)
This provides a summary of the numeric columns (like Age, AnnualIncome,
PurchaseAmount) and shows any missing values.

3. Identify Missing Values:

colSums(is.na(customer_data))
This command will count the number of missing values in each column.

4. Access Specific Columns Using $:

customer_data$Age # Access the Age column


customer_data$Gender # Access the Gender column

• Please Note $ operator is used to extract elements from list or data frame
by referring to the element’s namr.
• 5. Calculate the Average Purchase Amount:

mean(customer_data$Purchase.Amount, na.rm = TRUE)


This calculates the average purchase amount, ignoring
missing values (na.rm = TRUE).

6. Filter Customers with Purchases Greater than $200:

high_spenders <-
customer_data[customer_data$Purchase.Amount > 200, ]

print(high_spenders)
• Create a List for a Specific Customer:

customer_1 <- list(


CustomerID = customer_data$CustomerID[1],
Age = customer_data$Age[1],
Gender = customer_data$Gender[1],
AnnualIncome = customer_data$AnnualIncome[1],
ProductCategory = customer_data$ProductCategory[1],
Purchase.Amount =
customer_data$Purchase.Amount[1]
)

You might also like