library(readxl)
A4Q1 <- read_excel("C:/Users/hp/Downloads/A4Q1.xlsx")
observed <- table(A4Q1$flavor)
observed
## 
##  Chocolate      Mango Strawberry    Vanilla 
##         87         32         57         74
barplot(observed,
main = "flavor",
xlab = "flavor",
ylab = "Count",
col = rainbow(length(observed)))

View(A4Q1)
expected_proportions <- c(0.20, 0.20, 0.20, 0.40)
gof_test <- chisq.test(
  x = observed,
  p = expected_proportions
)
observed
## 
##  Chocolate      Mango Strawberry    Vanilla 
##         87         32         57         74
gof_test
## 
##  Chi-squared test for given probabilities
## 
## data:  observed
## X-squared = 41.6, df = 3, p-value = 4.878e-09
cohens_w <- sqrt(
  as.numeric(gof_test$statistic) / sum(observed)
)
cohens_w
## [1] 0.4079216
# A Chi-Square Goodness-of-Fit test was conducted to determine whether the observed frequencies of ice cream flavor purchases differed from
# The expected frequencies. The results showed a statistically significant difference, χ²(3) = 41.60, p = 4.878e-09 
# The difference was moderate,Cohen’s W = .41.