Import the original CSV
survey <- read.csv(
“/cloud/project/Beauty_Survey_Analysis.Rmd/Consumer Preferences for
Beauty and Cosmetic Products_November 27, 2026_14.03.csv”, na.strings =
“” )
Keep completed responses and exclude survey previews
clean_survey <- subset( clean_survey, Finished == “1” &
DistributionChannel != “preview” )
Convert these survey answers from text to numbers
clean_survey\(Q3 <-
as.numeric(clean_survey\)Q3) clean_survey\(Q4 <- as.numeric(clean_survey\)Q4)
clean_survey\(Q6_1 <-
as.numeric(clean_survey\)Q6_1) # Check the number of remaining
responses nrow(clean_survey)
[1] 7
Display the remaining survey answers
clean_survey[, c(“Q1”, “Q2”, “Q3”, “Q4”, “Q6_1”, “Q8”)]
Q1 Q2 Q3 Q4 Q6_1 Q8
8 2 2 3 3 4 3
9 2 3 3 2 4 3
10 2 4 3 2 3 1
11 2 3 5 3 5 3
12 4 3 3 2 3 2
13 2 4 2 2 4 1
14 2 1 1 1 3 1
Check for missing answers in the analysis variables
colSums(is.na(clean_survey[, c(“Q3”, “Q4”, “Q6_1”)]))
Q3 Q4 Q6_1
0 0 0
Simple regression: spending category predicted by purchase
frequency
simple_model <- lm(Q4 ~ Q3, data = clean_survey)
summary(simple_model)
Call:
lm(formula = Q4 ~ Q3, data = clean_survey)
Residuals:
8 9 10 11 12 13 14
0.7903 -0.2097 -0.2097 -0.1452 -0.2097 0.2581 -0.2742
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.8065 0.4424 1.823 0.1279
Q3 0.4677 0.1441 3.246 0.0228 *
—
Signif. codes: 0 ‘’ 0.001 ’’ 0.01 ’’ 0.05
‘.’ 0.1 ’ ’ 1
Residual standard error: 0.4288 on 5 degrees of freedom
Multiple R-squared: 0.6782, Adjusted R-squared: 0.6139
F-statistic: 10.54 on 1 and 5 DF, p-value: 0.02279
Multiple regression: add willingness to pay more for cruelty-free
products
multiple_model <- lm(Q4 ~ Q3 + Q6_1, data = clean_survey)
summary(multiple_model)
Call:
lm(formula = Q4 ~ Q3 + Q6_1, data = clean_survey)
Residuals:
8 9 10 11 12 13 14
0.72414 -0.27586 0.01724 -0.25862 0.01724 0.06897 -0.29310
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.06897 0.91850 0.075 0.944
Q3 0.34483 0.19809 1.741 0.157
Q6_1 0.29310 0.31838 0.921 0.409
Residual standard error: 0.4355 on 4 degrees of freedom
Multiple R-squared: 0.7345, Adjusted R-squared: 0.6017
F-statistic: 5.532 on 2 and 4 DF, p-value: 0.0705
Save only the variables used in the regressions
write.csv( clean_survey[, c(“Q3”, “Q4”, “Q6_1”)],
“/cloud/project/Beauty_Survey_Clean.csv”, row.names = FALSE )
Plot purchase frequency against spending category
plot( clean_survey\(Q3,
clean_survey\)Q4, main = “Purchase Frequency and Spending”, xlab
= “Purchase frequency category (1–5)”, ylab = “Spending category (1–5)”,
xlim = c(1, 5), ylim = c(1, 5), pch = 19, col = “steelblue” )
Add the simple regression line
abline(simple_model, col = “darkred”, lwd = 2)