library(readr)
hr <- read_csv('https://raw.githubusercontent.com/aiplanethub/Datasets/refs/heads/master/HR_comma_sep.csv')
## Rows: 14999 Columns: 10
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (2): Department, salary
## dbl (8): satisfaction_level, last_evaluation, number_project, average_montly...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
options(repos = c(CRAN = "https://cran.rstudio.com/"))
install.packages("plotly")
##
## The downloaded binary packages are in
## /var/folders/q1/gl10h4f94b3dsmnpk2jdysgr0000gn/T//Rtmp3vbT8m/downloaded_packages
install.packages("dplyr")
##
## The downloaded binary packages are in
## /var/folders/q1/gl10h4f94b3dsmnpk2jdysgr0000gn/T//Rtmp3vbT8m/downloaded_packages
library(plotly)
## Loading required package: ggplot2
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
Number 2
Interpret the results in technical terms (.5 point) For each
chi-square test, explain what the test’s p-value means
(significance).
- The P-value is extremely small, meaning that the probability of
these results being random is very small. There is a dependence between
salary and left the company.
Interpret the results in non-technical terms (1 point) For each
chi-square test, what do the results mean in non-techical terms.
- Those employees who had a high salary are mostly likely to have a
lower employee turnover while those with a low salary most likely will
have a higher turnover.
Create a plot that helps visualize the chi-square test (.5 point)
For each chi-square test, create a graph to help visualize the
difference between means, if any. The title must be the non-technical
interpretation.
ggplot(hr, aes(x = salary, fill = factor(left))) +
geom_bar(position = "dodge") +
labs(
title = "Employee Turnover by Salary",
x = "Salary",
y = "Count of Employees",
fill = "Left the Job"
) +
theme_minimal()

Number 3
Interpret the results in technical terms (.5 point) For each
chi-square test, explain what the test’s p-value means
(significance).
- The P-value is extremely small, meaning that the probability of
these results being random is very small. There is a dependence between
having a work accident and leaving the company.
Interpret the results in non-technical terms (1 point) For each
chi-square test, what do the results mean in non-techical terms.
- Those employees who had work accidents were more likely to not leave
the company probably due to things like receiving worker compensation or
fear of not finding another job at a different company following the
accident.
Create a plot that helps visualize the chi-square test (.5 point)
For each chi-square test, create a graph to help visualize the
difference between means, if any. The title must be the non-technical
interpretation.
ggplot(hr, aes(x = Work_accident, fill = factor(left))) +
geom_bar(position = "dodge") +
labs(
title = "Employee Turnover by Work Accident",
x = "Work Accident",
y = "Count of Employees",
fill = "Left the Job"
) +
theme_minimal()

Number 4
Interpret the results in technical terms (.5 point) For each
chi-square test, explain what the test’s p-value means
(significance).
- The P-value is extremely small, meaning that the probability of
these results being random is very small. There is a dependence between
getting a promotion and staying at the company.
Interpret the results in non-technical terms (1 point) For each
chi-square test, what do the results mean in non-techical terms.
- Those employees who got a promotion are more likely to stay at the
company.
Create a plot that helps visualize the chi-square test (.5 point)
For each chi-square test, create a graph to help visualize the
difference between means, if any. The title must be the non-technical
interpretation.
ggplot(hr, aes(x = promotion_last_5years, fill = factor(left))) +
geom_bar(position = "dodge") +
labs(
title = "Employee Turnover by Promotion in the Last 5 Years",
x = "Promotion",
y = "Count of Employees",
fill = "Left the Job"
) +
theme_minimal()
