Step 1: Installing packages

library(readxl)
library(ggplot2)

Loading the Packages

Step 2: Import and Name Dataset

DatasetA2 <- read_excel("C:/Users/Navya/Downloads/DatasetA2 (1).xlsx")

Dataset A2 is imported

Step 3: Create a Frequency Table

table(DatasetA2$FavoriteDrink)
## 
## Coffee   Soda    Tea  Water 
##     26     29     28     17

Step 4: Create a Bar Chart

ggplot(DatasetA2, aes(x = 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"             
  )

Step 5:Conduct the Chi-Square Goodness-of-Fit Test

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

Chi-squared test for given probabilities data: observed X-squared = 3.6, df = 3, p-value = 0.308

Interpretation A chi-square goodness-of-fit test indicated that the observed frequencies were not different from the expected frequencies, χ²(3) = 3.60, p = .308. Therefore, we fail to reject the null hypothesis. Students do not significantly prefer one beverage over another. Cohen’s W is NOT calculated because p > .05. Students do not significantly favor one beverage over anothe