Test 2- Department by Left
Chi-square test
chisq.test(hr$Department, hr$left)
##
## Pearson's Chi-squared test
##
## data: hr$Department and hr$left
## X-squared = 86.825, df = 9, p-value = 7.042e-15
Technical Interpretation
Since the p-value is <0.01, then we reject the Null hypothesis
and can state
that there is a difference in leaving based off what department you
work in.
The x2 of 86.825 indicates that it is more likely for a significant
relationship.
Non-technical Interpretation
Depanding on what department you work in there is a higher or lower
chance of you staying or leaving.
Hr leaves the most, Management leaves the least.
Plot
ggplot(hr, aes(x = as.factor(Department), fill = as.factor(left))) +
geom_bar(position = "fill") +
labs(
Title = "HR leaves the most, Management leaves the least",
x= "Department",
y = "Proportion",
fill = "left") +
theme_minimal()

Test 3- Salary by Left
Chi-square test
chisq.test(hr$salary, hr$left)
##
## Pearson's Chi-squared test
##
## data: hr$salary and hr$left
## X-squared = 381.23, df = 2, p-value < 2.2e-16
Technical Interpretation
Since the p-value is <0.01, then we reject the Null hypothesis
and can state
that there is a difference in leaving and your Salary.
The x2 of 381.23 indicates that there is strong difference.
Non-technical Interpretation
The higher salary the lower chance that you will leave
Plot
ggplot(hr, aes(x = as.factor(salary), fill = as.factor(left))) +
geom_bar(position = "fill") +
labs(
Title = "The Higher the Salary, the less Likely you are to Leave",
x= "Salary",
y = "Proportion",
fill = "left") +
theme_minimal()

Test 4- Time Spent by Left
Chi-square test
chisq.test(hr$time_spend_company, hr$left)
##
## Pearson's Chi-squared test
##
## data: hr$time_spend_company and hr$left
## X-squared = 2110.1, df = 7, p-value < 2.2e-16
Technical Interpretation
Since the p-value is <0.01, then we reject the Null hypothesis
and can state
that there is a difference in leaving and your time spent at the
company.
The x2 of 2110.1 indicates that there is strong difference
Non-technical Interpretation
After 7 years at the company people do not leave. But at year 5
people leave the most often.
Plot
ggplot(hr, aes(x = as.factor(time_spend_company), fill = as.factor(left))) +
geom_bar(position = "fill") +
labs(
Title = "After 7 Years Employee Stay at the Company",
x= "Years Spent at Company",
y = "Proportion",
fill = "left") +
theme_minimal()
