library(readxl)
library(ggpubr)
## Loading required package: ggplot2
library(rcompanion)
library(rmarkdown)
Team1Data <- read_excel("//apporto.com/dfs/SLU/Users/brentgallagher_slu/Desktop/Team1Data.xlsx")
table(Team1Data$Gender, Team1Data$Effective)
##        
##         No Yes
##   Man    6  51
##   Woman 11  32
# Table Man No: 6 Yes: 51
# Table Woman No: 11 Yes: 32
mytable <- table(Team1Data$Gender)
mytable
## 
##   Man Woman 
##    57    43
#Team Man:57 Woman:43
barplot(mytable, beside = TRUE,
        col = rainbow(nrow(mytable)),
        legend = rownames(mytable),
        main = "Gender and Effective",
        ylab = "Count")

chi_result <- chisq.test(mytable)
chi_result
## 
##  Chi-squared test for given probabilities
## 
## data:  mytable
## X-squared = 1.96, df = 1, p-value = 0.1615
# My table
# x-squared = 1.96, df = 1, p-value = 0.1615
# p-value > 0.05

chi_result$expected
##   Man Woman 
##    50    50
table(
  Team1Data$Gender,
  Team1Data$Effective,
  useNA = "no"
)
##        
##         No Yes
##   Man    6  51
##   Woman 11  32
sum(is.na(mytable))
## [1] 0
mytable <- table(
  Team1Data$Gender,
  Team1Data$Effective,
  useNA = "no"
)
cramer_v <- rcompanion::cramerV(mytable)
cramer_v
## Cramer V 
##   0.1984
# Cramer V = 0.1984
# Cramer V is a small association.
# A Chi-Square Test of Independence was conducted to determine if there was an association between gender and effectiveness.
# The results showed that there was not sufficient evidence of an association between the two variables.
# x-squared = 1.96, df = 1, p-value = 0.1615, < .05.
# The association was small CramerV = 0.20