library(ggplot2)
library(readxl)
library(rcompanion)
DatasetA2 <- read_excel("C:/Users/user/Downloads/DatasetA2.xlsx")
table(DatasetA2$StudentID)
table(DatasetA2$FavoriteDrink)
Create a Bar Chart
ggplot(DatasetA2, aes(FavoriteDrink, fill = FavoriteDrink)) +geom_bar() + labs(
x = "FavoriteDrink",
y = "Frequency",
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),
legend.position = "none"
)
Chi-Square Goodness-of-Fit Test
observed <- c(26,29 ,28, 17)
expected <- c(.26, .29, .28, .17)
chisq.test(x = observed, p = expected)
observed <- c(26,29 ,28, 17)
chisq.test(x = observed, p = expected)
A chi-square goodness-of-fit test indicated that the observed frequencies were were not different from the expected frequencies, χ²(df) = 8.8601e-31, p =1.The association between the variables strong