library(readxl)
library(ggplot2)
DatasetA2 <- read_excel("/Users/srikarthikeya/Downloads/DatasetA2.xlsx")
table(DatasetA2$FavoriteDrink)
##
## Coffee Soda Tea Water
## 26 29 28 17
ggplot(DatasetA2, aes(x = FavoriteDrink, fill = FavoriteDrink)) +
geom_bar() +
labs(
x = "FavoriteDrink",
y = "No. of Students",
title = "Distribution of FavoriteDrink"
) +
theme(
text = element_text(size = 14),
axis.title = element_text(size = 14),
axis.text = element_text(size = 14),
plot.title = element_text(size = 14),
)
The Observed values for the FavoriteDrink is (Coffee = 26, Soda = 29, tea = 28, water = 17 )
observed <- c(26, 29, 28, 17)
expected <- c(0.25, 0.25, 0.25, 0.25)
chisq.test(x = observed, p = expected)
##
## Chi-squared test for given probabilities
##
## data: observed
## X-squared = 3.6, df = 3, p-value = 0.308
P- Value = 0.308 which is greater than 0.05 that means the p-value is statistically insignificant.
Since the p-value is insignificant we don’t have to calculate the Cohen’s W value.
A chi-square goodness-of-fit test indicated that the observed frequencies were different from the expected frequencies, χ²(2) = 3.6, p = 0.308.