library(readxl)
library(ggpubr)
## Loading required package: ggplot2
library(ggplot2)

icecream <- read_excel("C:/Users/rmich/Desktop/icecream.xlsx")
observed <- table(icecream$flavor)
observed
## 
##  Chocolate      Mango Strawberry    Vanilla 
##         87         32         57         74
barplot(observed,
        main = "Ice Cream$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 observed ice cream purchase frequencies and the expected frequencies (20% chocolate, 20% strawberry, 20% mango, and 40% vanilla). The results show 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).