library(readxl)
FP2 <- read_excel("~/Library/CloudStorage/OneDrive-SaintLouisUniversity/AA-5221-12/Final Project/Chi-Square/FP2.xlsx")
FP2_table <- table(FP2$Membership, FP2$Repeat_Purchase)
FP2_table
##
## No Yes
## Member 21 39
## Non-member 34 26
barplot(
FP2_table,
beside = TRUE,
col = rainbow(nrow(FP2_table)),
legend = rownames(FP2_table)
)
## Chi-Square Test
chi_result <- chisq.test(FP2_table)
chi_result
##
## Pearson's Chi-squared test with Yates' continuity correction
##
## data: FP2_table
## X-squared = 4.8336, df = 1, p-value = 0.02791
chi_result$expected
##
## No Yes
## Member 27.5 32.5
## Non-member 27.5 32.5
cramer_v <- rcompanion::cramerV(FP2_table)
cramer_v
## Cramer V
## 0.2174
# A Chi-Square Test of Independence was conducted to determine if there was an association between membership status and repeat purchasing.
# The results showed that there was an association between the two variables, χ²(1) = 4.83, p = .028.
# The association was small (Cramer's V = .22).