library(readxl)
library(ggpubr)
## Loading required package: ggplot2
# I didn't have line 3 in first attempt.
library(rmarkdown)
# I didnt have have line 5 in first attempt.
A4Q1 <- read_excel("//apporto.com/dfs/SLU/Users/brentgallagher_slu/Desktop/A4Q1.xlsx")
table(A4Q1$flavor)
##
## Chocolate Mango Strawberry Vanilla
## 87 32 57 74
observed <- table(A4Q1$flavor)
observed
##
## Chocolate Mango Strawberry Vanilla
## 87 32 57 74
## Chcolate Mango Strawberry Vanilla
## 87 32 57 74
# I didnt have lines 11 and 12 in first attempt.
barplot(observed,
main = "Ice Cream Purchases",
xlab = "flavor",
ylab = "Count",
col = rainbow(length(observed)))

# I didnt have line 15 named Ice Cream Purchases in first attempt.
expected <- c(.2, .2, .2, .4)
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
## Data: Observed
## X-Squared = 41.6, df = 3, p-value = 4.878e-09
# I dint have lines 23 and 24 in first attempt.
w <- sqrt(as.numeric(chi_result$statistic) / sum(observed))
w
## [1] 0.4079216
# Chi-Square Goodness-of-Fit test was conducted to determine if there was a difference between the observed ice cream flavor frequencies and the expected ice cream flavor frequencies.
# There was a significant difference between the observed and expected frequencies, x-squared(3) = 41.6, p <.001.
# I did not have line 29 in my fist attempt.
# The difference was moderate (Cohen's W = ;41).
# I did not round up Cohens output in first attempt.