library(readr)
## Warning: package 'readr' was built under R version 4.4.2
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.4.2
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.4.2
## 
## 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
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.

Conduct Test 1

t_test1 <- t.test(satisfaction_level ~ left, data = hr)

Display Test 1

ggplot(hr, aes(x = factor(left), y = satisfaction_level)) +
  geom_boxplot() +
  labs(title = "Comparison of Satisfaction Levels between Employees Who Stayed and Left",
       x = "Left (0 = Stayed, 1 = Left)",
       y = "Satisfaction Level")

Technical Interpretation: The p-value here tells us if there’s a statistically significant difference in satisfaction levels between employees who left (left = 1) and those who stayed (left = 0). A p-value < 0.05 suggests a significant difference.

Non-Technical Interpretation: This test helps us understand if employees who left the company had different satisfaction levels compared to those who stayed. A low p-value would indicate that dissatisfaction is likely linked to employees leaving.

Conduct Test 2

t_test2 <- t.test(last_evaluation ~ left, data = hr)

Display Test 2

ggplot(hr, aes(x = factor(left), y = last_evaluation)) +
  geom_boxplot() +
  labs(title = "Comparison of Last Evaluation Scores between Employees Who Stayed and Left",
       x = "Left (0 = Stayed, 1 = Left)",
       y = "Last Evaluation Score")

Technical Interpretation: The p-value shows whether there’s a significant difference in the last evaluation scores between those who left and those who stayed.

Non-Technical Interpretation: This test checks if employees who left received different performance evaluations than those who stayed. A significant result might indicate that high or low evaluations correlate with attrition.

Conduct Test 3

t_test3 <- t.test(average_montly_hours ~ left, data = hr)

Display Test 3

ggplot(hr, aes(x = factor(left), y = average_montly_hours)) +
  geom_boxplot() +
  labs(title = "Comparison of Average Monthly Hours between Employees Who Stayed and Left",
       x = "Left (0 = Stayed, 1 = Left)",
       y = "Average Monthly Hours")

Technical Interpretation: The p-value tells us if there’s a statistically significant difference in the average monthly hours worked by employees who left versus those who stayed.

Non-Technical Interpretation: This test helps us determine if overwork or underwork could be a reason employees are leaving. A significant result suggests that employees working different hours may have higher attrition rates.

Conduct Test 4

t_test4 <- t.test(time_spend_company ~ left, data = hr)

Display Test 4

ggplot(hr, aes(x = factor(left), y = time_spend_company)) +
  geom_boxplot() +
  labs(title = "Comparison of Tenure between Employees Who Stayed and Left",
       x = "Left (0 = Stayed, 1 = Left)",
       y = "Years Spent at Company")

Technical Interpretation: This p-value tests if there’s a significant difference in the number of years employees have spent at the company between those who left and those who stayed.

Non-Technical Interpretation: This test shows if the duration of employment impacts the likelihood of employees leaving. A significant p-value would indicate that those who stayed may have a different tenure than those who left.