The research web page can be found here https://rpubs.com/ivanKomak/1397910.
library(readxl)
library(ggplot2)
library(rcompanion)
# Step 3: Import Dataset
DataSetB2 <- read_excel("/Users/komakechivan/Downloads/DatasetB2.xlsx")
tab_B2 <- table(DataSetB2$StudentType, DataSetB2$PetOwnership)
print(tab_B2)
##
## No Yes
## Domestic 27 25
## International 23 25
ggplot(DataSetB2, aes(x = StudentType, fill = PetOwnership)) +
geom_bar(position = "dodge") +
labs(
x = "Student Type",
y = "Pet Ownership Status",
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)
)
chisq_results_B2 <- chisq.test(tab_B2)
chisq_results_B2
##
## Pearson's Chi-squared test with Yates' continuity correction
##
## data: tab_B2
## X-squared = 0.040064, df = 1, p-value = 0.8414
cramerV(tab_B2)
## Cramer V
## 0.04003