library(readxl)
# 1. Import: a window opens, pick your Customer_Loyalty_Survey .xlsx file
raw <- read_excel("Customer Loyalty Survey - CSUB_November 29, 2026_12.01.xlsx", col_types = "text")
raw <- raw[-1, ] # drop the Qualtrics question-text row
# 2. Clean: keep only complete, non-test responses
keep <- as.numeric(raw$Status) == 0 & as.numeric(raw$Finished) == 1 & as.numeric(raw$Progress) == 100
raw <- raw[keep, ]
d <- data.frame(
age_group = as.numeric(raw$Q1),
contract_type = as.numeric(raw$Q2),
tenure = as.numeric(raw$Q3),
addons = raw$Q4,
churn_intent = as.numeric(raw$Q5),
plan_choice = as.numeric(raw$Q6),
price_fair = as.numeric(raw$Q7_1),
support_sat = as.numeric(raw$Q8_1),
switch_hassle = as.numeric(raw$Q9_1),
commitment = as.numeric(raw$Q10_1)
)
# Replace missing numbers with the column mean (addons is text, so it is skipped)
for (v in setdiff(names(d), "addons")) d[[v]][is.na(d[[v]])] <- mean(d[[v]], na.rm = TRUE)
write.csv(d, "clean_data.csv", row.names = FALSE) # saved in your working folder
nrow(d) # should say 11
## [1] 11
library(ggplot2) # if not installed, run install.packages("ggplot2") once in the Console
ggplot(d, aes(x = support_sat, y = churn_intent)) +
geom_jitter(width = 0.1, height = 0.1, size = 3, alpha = 0.7) +
geom_smooth(method = "lm", se = TRUE, color = "red") +
labs(title = "Support satisfaction vs. intent to cancel",
x = "Satisfaction with technical support (1-5)",
y = "Intent to cancel/switch (1-5)") +
theme_minimal()
## `geom_smooth()` using formula = 'y ~ x'

# 3. Simple regression
m1 <- lm(churn_intent ~ support_sat, data = d)
summary(m1)
##
## Call:
## lm(formula = churn_intent ~ support_sat, data = d)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.2368 -0.5461 -0.3158 0.7237 1.7632
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.3947 1.2905 0.306 0.767
## support_sat 0.4605 0.4044 1.139 0.284
##
## Residual standard error: 1.063 on 9 degrees of freedom
## Multiple R-squared: 0.1259, Adjusted R-squared: 0.02881
## F-statistic: 1.297 on 1 and 9 DF, p-value: 0.2842
# 4. Multiple regression
m2 <- lm(churn_intent ~ support_sat + price_fair + switch_hassle + commitment, data = d)
summary(m2)
##
## Call:
## lm(formula = churn_intent ~ support_sat + price_fair + switch_hassle +
## commitment, data = d)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.2379 -0.5536 -0.1569 0.5913 1.3553
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.39973 1.73379 1.384 0.216
## support_sat 0.70773 0.49545 1.428 0.203
## price_fair -0.31523 0.32569 -0.968 0.370
## switch_hassle -0.57134 0.40341 -1.416 0.206
## commitment 0.09791 0.55856 0.175 0.867
##
## Residual standard error: 1.04 on 6 degrees of freedom
## Multiple R-squared: 0.4426, Adjusted R-squared: 0.07098
## F-statistic: 1.191 on 4 and 6 DF, p-value: 0.4031