library(readxl)
library(ggplot2)
A5Q1_1 <- read_excel("/Users/murphy/Downloads/A5Q1-1.xlsx")
observed <- table(A5Q1_1$flavor)
observed
##
## Chocolate Mango Strawberry Vanilla
## 87 32 57 74
Chocolate Mango Strawberry Vanilla 87 32 57 74
barplot(observed,
main = "Ice Cream Purchases",
xlab = "Flavor",
ylab = "Purchases",
col = rainbow(length(observed)))
corrected the title of the barplot from Flavors to Ice Cream Purchases
expected <- c(0.20, 0.20, 0.20, 0.40)
chi_result <- chisq.test(x = observed, p = expected)
chi_result
##
## Chi-squared test for given probabilities
##
## data: observed
## X-squared = 41.6, df = 3, p-value = 4.878e-09
Chi-squared test for given probabilities data: observed X-squared = 41.6, df = 3, p-value = 4.878e-09
w <- sqrt(as.numeric(chi_result$statistic) / sum(observed))
w
## [1] 0.4079216
Effect Size - 0.41
A Chi-Square Goodness of Fit test was conducted to determine if there was a difference between the observed ice cream flavor purchased frequencies and the expected frequencies. The results showed that there was a difference between the observed and expected frequencies, χ²(3) = 41.60 p < .001. The difference was moderate, (Cohen’s W = 0.41).
library(rmarkdown)