## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ purrr     1.1.0
## ✔ forcats   1.0.1     ✔ stringr   1.5.2
## ✔ ggplot2   4.0.0     ✔ tibble    3.3.0
## ✔ lubridate 1.9.4     ✔ tidyr     1.3.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
## 
## 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
## 
## 
## 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 1 -

## 
##  Welch Two Sample t-test
## 
## data:  hr$Satisfaction by hr$left_new
## t = 46.636, df = 5167, p-value < 2.2e-16
## alternative hypothesis: true difference in means between group Stayed (0) and group Left (1) is not equal to 0
## 95 percent confidence interval:
##  0.2171815 0.2362417
## sample estimates:
## mean in group Stayed (0)   mean in group Left (1) 
##                0.6668096                0.4400980

The p-value is extremely small (p < 2.2e-16). Since the p-value is far below the conventional significance level of 0.01, we reject the null hypothesis. This indicates that the true mean satisfaction level for employees who left the company is statistically significantly different from those who stayed.

T-Test 2 -

## 
##  Welch Two Sample t-test
## 
## data:  hr$Evaluation by hr$left_new
## t = -0.72534, df = 5154.9, p-value = 0.4683
## alternative hypothesis: true difference in means between group Stayed (0) and group Left (1) is not equal to 0
## 95 percent confidence interval:
##  -0.009772224  0.004493874
## sample estimates:
## mean in group Stayed (0)   mean in group Left (1) 
##                0.7154734                0.7181126

The p-value is 0.4683. Since the p-value (0.4683) is much greater than the conventional significance level of 0.01, we fail to reject the null hypothesis. This indicates that there is NO statistically significant difference between the true mean last evaluation score for employees who left and those who stayed.

T-Test 3 -

## 
##  Welch Two Sample t-test
## 
## data:  hr$Projects by hr$left_new
## t = -2.1663, df = 4236.5, p-value = 0.03034
## alternative hypothesis: true difference in means between group Stayed (0) and group Left (1) is not equal to 0
## 95 percent confidence interval:
##  -0.131136535 -0.006540119
## sample estimates:
## mean in group Stayed (0)   mean in group Left (1) 
##                 3.786664                 3.855503

The p-value is 0.03034. Since the p-value (0.03034) is greater than the required significance level (alpha = 0.01), we fail to reject the null hypothesis. This indicates that there is NO statistically significant difference in the true mean number of projects between employees who left and those who stayed, at the 1% significance level.

T-Test 4 -

## 
##  Welch Two Sample t-test
## 
## data:  hr$AvgHours by hr$left_new
## t = -7.5323, df = 4875.1, p-value = 5.907e-14
## alternative hypothesis: true difference in means between group Stayed (0) and group Left (1) is not equal to 0
## 95 percent confidence interval:
##  -10.534631  -6.183384
## sample estimates:
## mean in group Stayed (0)   mean in group Left (1) 
##                 199.0602                 207.4192

The p-value is 5.907e-14. Since this p-value is extremely small (far below the 0.05 or even 0.01 significance levels), we strongly reject the null hypothesis. This establishes a statistically significant difference in the true mean average monthly hours worked between the employees who left (mean=207.42) and those who remained (mean=199.06). The difference is approximately 8.36 hours per month.