library(readr)
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
library(ggplot2)
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.
t.test(satisfaction_level ~ left, data =hr)
##
## Welch Two Sample t-test
##
## data: satisfaction_level by left
## t = 46.636, df = 5167, p-value < 2.2e-16
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
## 0.2171815 0.2362417
## sample estimates:
## mean in group 0 mean in group 1
## 0.6668096 0.4400980
ggplot(hr, aes(x = factor(left), y = satisfaction_level)) +
geom_boxplot(fill = c("lightblue","pink")) +
labs(title = "Employees Who Left were Less Satisfied", x = "Left (0 = No, 1 = Yes)", y = "Satisfaction Level")
p-value interpretation: The p-value is very small, therefore the correlation between satisfaction level and employees who left is significant.
non-technical interpretation: Employees who left the company were typically not satisfied.
t.test(last_evaluation ~ left, data =hr)
##
## Welch Two Sample t-test
##
## data: last_evaluation by left
## t = -0.72534, df = 5154.9, p-value = 0.4683
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
## -0.009772224 0.004493874
## sample estimates:
## mean in group 0 mean in group 1
## 0.7154734 0.7181126
ggplot(hr, aes(x = factor(left), y = last_evaluation)) +
geom_boxplot(fill = c("lightblue","pink")) +
labs(title = "There is No Correlation Between Employees Who Left and Their Last Evaluation", x = "Left (0 = No, 1 = Yes)", y = "Satisfaction Level")
p-value interpretation: The p-value is 0.4683, therefore there is no correlation between employees leaving and their last evaluation.
non-technical interpretation: Therefore depending what you received on your last evaluation does not result in leaving the evaluation.
t.test(average_montly_hours ~ left, data =hr)
##
## Welch Two Sample t-test
##
## data: average_montly_hours by left
## t = -7.5323, df = 4875.1, p-value = 5.907e-14
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
## -10.534631 -6.183384
## sample estimates:
## mean in group 0 mean in group 1
## 199.0602 207.4192
ggplot(hr, aes(x = factor(left), y = average_montly_hours)) +
geom_boxplot(fill = c("lightblue","pink")) +
labs(title = "The employees who left worked the most average monthly hours", x = "Left (0 = No, 1 = Yes)", y = "Average Monthly Hours")
p-value interpretation: The p-value is very small, therefore there is a correlation between employees leaving and their average monthly hours being above average.
non-technical interpretation: Therefore if employees are overworked they are more likely to leave a company
t.test(number_project ~ left, data =hr)
##
## Welch Two Sample t-test
##
## data: number_project by left
## t = -2.1663, df = 4236.5, p-value = 0.03034
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
## -0.131136535 -0.006540119
## sample estimates:
## mean in group 0 mean in group 1
## 3.786664 3.855503
ggplot(hr, aes(x = factor(left), y = number_project)) +
geom_boxplot(fill = c("lightblue","pink")) +
labs(title = "The more projects you have you tend to be more likely to leave", x = "Left (0 = No, 1 = Yes)", y = "number_project")
p-value interpretation: The p-value is 0.03034, therefore there is a correlation between employees leaving and the amount of projects they did .
non-technical interpretation: Therefore if employees are assigned too many porjects they are more likely to leave a company