library(readxl)
library(ggplot2)
library(rcompanion)
DatasetB2 <- read_excel("C:/Users/joyce/Downloads/DatasetB2.xlsx")
tab <- table(DatasetB2$StudentType, DatasetB2$PetOwnership)

The contingency table shows the number of domestic and international student who own and do not own pet It will be used to test if student type is associated with pet ownership

ggplot(DatasetB2, aes(x = StudentType, fill = PetOwnership)) +
  geom_bar(position = "dodge") +               
  labs(
    x = "Student Type",
    y = "Frequency",
    title = "Pet Ownership by Student Type"
  ) +
  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"                 
  ) 

The bar chart shows similar levels of pet ownership between domestic and international student

chisq.test(tab)
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  tab
## X-squared = 0.040064, df = 1, p-value = 0.8414

Conducts a Chi-square Test of independence to see if students type is associated with pet ownership

Effect size is not calculated because the p-value is not statistically significant

The Chi-Square Test of Independence indicated there was not a significant association between Student type and pet ownership, χ²(1) = 0.04, p = .841. The association between the two variables was not significant,effect size was not calculated.