library(ggplot2)
library(readxl)
library(rcompanion)
DatasetA2 <- read_excel("C:/Users/user/Downloads/DatasetA2.xlsx")
table(DatasetA2$FavoriteDrink)
## 
## Coffee   Soda    Tea  Water 
##     26     29     28     17

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)
## 
##  Chi-squared test for given probabilities
## 
## data:  observed
## X-squared = 8.8601e-31, df = 3, p-value = 1
observed <- c(26,29 ,28, 17) 
chisq.test(x = observed, p = expected)
## 
##  Chi-squared test for given probabilities
## 
## data:  observed
## X-squared = 8.8601e-31, df = 3, p-value = 1

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