library(readxl)
## Warning: package 'readxl' was built under R version 4.4.3
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.4.3
library(rcompanion)
## Warning: package 'rcompanion' was built under R version 4.4.3
A5Q1 <- read_excel("C:/Users/vinay_17rmu0l/Desktop/A5Q1.xlsx")
observed <- table(A5Q1$flavor)
observed
## 
##  Chocolate      Mango Strawberry    Vanilla 
##         87         32         57         74
barplot(observed,
        main = "flavor",
        xlab = "flavor",
        ylab = "Count",
        col = rainbow(length(observed)))

expected <- c(.20, .20, .20, .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
w <- sqrt(as.numeric(chi_result$statistic) / sum(observed))
w
## [1] 0.4079216

A Chi-Square Goodness of Fit test was conducted to determine if there was a difference between the ice cream purchases and the expected distribution.

The results showed that there was a difference between the observed and expected frequencies, χ²(2) = 41.6, p = < 0.001.

The difference was moderate, (Cohen’s W = .41).