Research Scenario A

The research web page can be found here https://rpubs.com/ivanKomak/1397885.

library(readxl)
library(ggplot2)
library(rcompanion)

# Step 3: Import Dataset
DataSetA2 <- read_excel("/Users/komakechivan/Downloads/DatasetA2.xlsx")
Create a frequency table
table(DataSetA2$FavoriteDrink)
## 
## Coffee   Soda    Tea  Water 
##     26     29     28     17
Create a bar chart
ggplot(DataSetA2, aes(x = FavoriteDrink, fill = FavoriteDrink)) +
  geom_bar() +
  labs(
    x = "Beverage Type",
    y = "Frequency",
    title = "Distribution of Student Beverage Preferences"
  ) +
  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"
  )

Conduct the Chi-Square Goodness-of-Fit Test
observed_A2 <- c(25, 31, 28, 16)
expected_A2 <- c(0.25, 0.25, 0.25, 0.25)
chisq.test(x = observed_A2, p = expected_A2)
## 
##  Chi-squared test for given probabilities
## 
## data:  observed_A2
## X-squared = 5.04, df = 3, p-value = 0.1689

Calculate Cohen’s W (Effect Size)

observed_table <- as.table(c(Coffee=25, Soda=31, Tea=28, Water=16))

the effect size calculation

cramerV(observed_table)
## Cramer V 
##       NA

Interpretaion

A chi-square goodness-of-fit test indicated that the observed frequencies were not different from the expected frequencies, χ²(3) = 5.04, p = .169. The association between the variables was weak (Cramer’s V = .13).