library(readxl)
library(ggplot2)
DatasetA2 <- read_excel("C:/Users/joyce/Downloads/DatasetA2.xlsx")
table(DatasetA2$FavoriteDrink)
##
## Coffee Soda Tea Water
## 26 29 28 17
This frequency table shows how many students selected each drink. Soda was the most preferred with 29 student. Followed by tea 28, coffee 26, water was the least preferred.
ggplot(DatasetA2, aes(x = FavoriteDrink, fill = FavoriteDrink)) +
geom_bar() +
labs(
x = "Favorite Drink",
y = "Frequency",
title = "Distribution of Favorite Drink"
) +
theme(
text = element_text(size = 14),
axis.title = element_text(size = 14),
axis.text = element_text(size = 14),
plot.title = element_text(size = 14),
legend.position = "none"
)
Soda and tea are the most preferred drink, while water is least preferred. The drinks are not equally preferred.
observed <- c(26, 29, 28, 17)
expected <- c(.25, .25, .25, .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
The p-value .308 is greater than .05, this means the p-value is not statistically significant
Step 7 the p-value is not statistically significant, the effect size is not calculated
A chi-square goodness-of-fit test indicated that the observed frequencies were not different from the expected frequencies, χ²(3) = 3.6, p = .308.