This lab uses principal component analysis (PCA) and perceptual maps to compare how consumers with and without college degrees rate grocery stores in Bakersfield. The results can help marketers understand brand positioning and identify possible competitive advantages.
The two provided CSV files contain grocery-store ratings for Yelp, value, convenience, assortment, service, delivery service, and smart apps.
Bakersfield_Grocery1.csv represents consumers with a college degree.
Bakersfield_Grocery2.csv represents consumers without a college degree.
Both files should be uploaded to RStudio Cloud. The R Markdown code will analyze both datasets in one Knit.
A perceptual map helps explain how consumers view different grocery stores based on their ratings.
Stores located near each other on the map have similar rating patterns. Attribute arrows show the direction in which ratings increase.
The two principal components explain part of the differences between stores.
# Install ggbiplot in the Console first if needed:
# install.packages("ggbiplot")
library(ggbiplot)
library(ggplot2)
# Import first dataset
data1 <- read.csv(
"Bakersfield_Grocery1.csv",
header = TRUE,
row.names = 1
)
# Display dataset
print(data1)
## Yelp Value Convenience Assortment Service Delivery_ser
## Trader Joe's 4.5 4.0 3.0 3 5 3
## Carniceria La Carreta 4.0 2.0 4.0 4 5 3
## Sprouts 4.0 3.0 3.0 3 5 4
## Albertson's 3.0 2.0 5.0 3 4 4
## FoodMaxx 2.0 3.0 3.0 3 4 3
## Vallarta 3.0 3.0 3.0 4 5 3
## Aldi 3.5 4.0 3.0 3 5 5
## Winco 4.0 5.0 5.0 5 5 4
## Walmart 2.5 4.5 4.5 5 4 5
## Smart_Apps
## Trader Joe's 4
## Carniceria La Carreta 0
## Sprouts 4
## Albertson's 4
## FoodMaxx 3
## Vallarta 0
## Aldi 0
## Winco 4
## Walmart 4
# Create groups
site.groups1 <- factor(c(
rep("a", 3),
rep("b", 3),
rep("c", 3)
))
# Principal Component Analysis
data.pca1 <- prcomp(
data1,
center = TRUE,
scale. = TRUE
)
# Display PCA summary
print(summary(data.pca1))
## Importance of components:
## PC1 PC2 PC3 PC4 PC5 PC6 PC7
## Standard deviation 1.5609 1.3596 0.9975 0.9758 0.79712 0.31373 0.18494
## Proportion of Variance 0.3481 0.2641 0.1421 0.1360 0.09077 0.01406 0.00489
## Cumulative Proportion 0.3481 0.6121 0.7543 0.8903 0.98105 0.99511 1.00000
# Create Figure 3
g1 <- ggbiplot(
data.pca1,
obs.scale = 1,
var.scale = 1,
groups = site.groups1,
ellipse = TRUE,
circle = TRUE,
labels = rownames(data1)
)
# Customize graph
g1 <- g1 + scale_color_discrete(
name = ""
)
g1 <- g1 + theme(
legend.direction = "horizontal",
legend.position = "top"
)
g1 <- g1 + ggtitle(
"Figure 3: Consumers With a College Degree"
)
# Display Figure 3
print(g1)
# Import second dataset
data2 <- read.csv(
"Bakersfield_Grocery2.csv",
header = TRUE,
row.names = 1
)
# Display dataset
print(data2)
## Yelp Value Convenience Assortment Service Delivery_ser
## Trader Joe's 4 2.0 3.0 3 4 2
## Carniceria La Carreta 5 5.0 5.0 4 5 2
## Sprouts 4 3.0 3.0 3 3 3
## Albertson's 3 2.0 5.0 3 4 4
## FoodMaxx 4 3.0 3.0 3 4 3
## Vallarta 5 5.0 5.0 4 5 3
## Aldi 4 4.0 3.0 3 5 5
## Winco 5 5.0 5.0 5 5 4
## Walmart 4 4.5 4.5 5 4 5
## Smart_Apps
## Trader Joe's 2
## Carniceria La Carreta 0
## Sprouts 2
## Albertson's 3
## FoodMaxx 3
## Vallarta 0
## Aldi 0
## Winco 3
## Walmart 4
# Create groups
site.groups2 <- factor(c(
rep("a", 3),
rep("b", 3),
rep("c", 3)
))
# Principal Component Analysis
data.pca2 <- prcomp(
data2,
center = TRUE,
scale. = TRUE
)
# Display PCA summary
print(summary(data.pca2))
## Importance of components:
## PC1 PC2 PC3 PC4 PC5 PC6 PC7
## Standard deviation 1.8707 1.3224 0.9390 0.76890 0.47239 0.18816 0.1426
## Proportion of Variance 0.4999 0.2498 0.1260 0.08446 0.03188 0.00506 0.0029
## Cumulative Proportion 0.4999 0.7497 0.8757 0.96016 0.99204 0.99710 1.0000
# Create Figure 4
g2 <- ggbiplot(
data.pca2,
obs.scale = 1,
var.scale = 1,
groups = site.groups2,
ellipse = TRUE,
circle = TRUE,
labels = rownames(data2)
)
# Customize graph
g2 <- g2 + scale_color_discrete(
name = ""
)
g2 <- g2 + theme(
legend.direction = "horizontal",
legend.position = "top"
)
g2 <- g2 + ggtitle(
"Figure 4: Consumers Without a College Degree"
)
# Display Figure 4
print(g2)
Article: 6 Reasons to Learn R for Business [2021]
Author: Matt Dancho
Link: https://www.business-science.io/business/2020/12/17/six-reasons-to-use-R-for-business-2021.html
After reading the article “6 Reasons to Learn R for Business,” I learned how useful R can be for businesses, especially in marketing and data analytics. One thing I found interesting was how R can help businesses analyze large amounts of data and identify trends. This is important because I want to work in marketing analytics and understand consumer behavior.
Another thing I learned was how R can create graphs and visualizations that make data easier to understand. This could help me present marketing results to managers and companies.
Lastly, I learned that R Markdown allows people to combine their analysis, graphs, and explanations into one report. I believe learning R will help me improve my analytical skills, understand customer preferences, and make better marketing decisions in my future career.
The sample size used in this survey exercise is small. Therefore, the results should not be generalized to the entire population of Bakersfield.
The perceptual maps help identify patterns in consumer ratings, but they do not prove that education causes these differences.
Xu, Z. (2021). Brand/Product Positioning & Perceptual Mapping.
https://rpubs.com/utjimmyx/brand_positioning
Displayr. Focusing the Results of Correspondence Analysis in Displayr.
https://www.displayr.com/focusing-the-results-of-correspondence-analysis-in-displayr/
Kuhfeld, W. F. Marketing Research: Uncovering Competitive Advantages. SAS Institute Inc.
Biplot of PCs Using ggbiplot Function.
https://agroninfotech.blogspot.com/2020/06/biplot-for-principal-component-analysis.html
Dancho, M. (2020). 6 Reasons to Learn R for Business [2021].
https://www.business-science.io/business/2020/12/17/six-reasons-to-use-R-for-business-2021.html
Nenadic, O., & Greenacre, M. (2007). Correspondence Analysis in R, with Two- and Three-Dimensional Graphics: The ca Package. Journal of Statistical Software, 20(3).
https://goedoc.uni-goettingen.de/bitstream/handle/1/5892/Nenadic.pdf?sequence=1
The R Project for Statistical Computing.
R Markdown.