library(readxl)
library(ggplot2)
library(rcompanion)
DatasetA1 <- read_excel("C:/Users/Leyav/Downloads/DatasetA2.xlsx")
table2 <- table(DatasetA1$FavoriteDrink)
table2
##
## Coffee Soda Tea Water
## 26 29 28 17
ggplot(DatasetA1, aes(x =FavoriteDrink , fill = FavoriteDrink)) +
geom_bar() +
labs(
x = "FavouriteDrink",
y = "Frequency",
title = "Distribution of favourite 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"
)
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 is 0.308 that means the data is not significant and effect size is calculated only if the p-value was statistically significant hence Cohen’s W(effect size) test is not required.
A chi-square goodness-of-fit test indicated that the observed frequencies were different from the expected frequencies, χ²(2) = 3.6, p = .308.