## spc_tbl_ [14,999 × 10] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
##  $ satisfaction_level   : num [1:14999] 0.38 0.8 0.11 0.72 0.37 0.41 0.1 0.92 0.89 0.42 ...
##  $ last_evaluation      : num [1:14999] 0.53 0.86 0.88 0.87 0.52 0.5 0.77 0.85 1 0.53 ...
##  $ number_project       : num [1:14999] 2 5 7 5 2 2 6 5 5 2 ...
##  $ average_montly_hours : num [1:14999] 157 262 272 223 159 153 247 259 224 142 ...
##  $ time_spend_company   : num [1:14999] 3 6 4 5 3 3 4 5 5 3 ...
##  $ Work_accident        : num [1:14999] 0 0 0 0 0 0 0 0 0 0 ...
##  $ left                 : num [1:14999] 1 1 1 1 1 1 1 1 1 1 ...
##  $ promotion_last_5years: num [1:14999] 0 0 0 0 0 0 0 0 0 0 ...
##  $ Department           : chr [1:14999] "sales" "sales" "sales" "sales" ...
##  $ salary               : chr [1:14999] "low" "medium" "medium" "low" ...
##  - attr(*, "spec")=
##   .. cols(
##   ..   satisfaction_level = col_double(),
##   ..   last_evaluation = col_double(),
##   ..   number_project = col_double(),
##   ..   average_montly_hours = col_double(),
##   ..   time_spend_company = col_double(),
##   ..   Work_accident = col_double(),
##   ..   left = col_double(),
##   ..   promotion_last_5years = col_double(),
##   ..   Department = col_character(),
##   ..   salary = col_character()
##   .. )
##  - attr(*, "problems")=<externalptr>
##  satisfaction_level last_evaluation  number_project  average_montly_hours
##  Min.   :0.0900     Min.   :0.3600   Min.   :2.000   Min.   : 96.0       
##  1st Qu.:0.4400     1st Qu.:0.5600   1st Qu.:3.000   1st Qu.:156.0       
##  Median :0.6400     Median :0.7200   Median :4.000   Median :200.0       
##  Mean   :0.6128     Mean   :0.7161   Mean   :3.803   Mean   :201.1       
##  3rd Qu.:0.8200     3rd Qu.:0.8700   3rd Qu.:5.000   3rd Qu.:245.0       
##  Max.   :1.0000     Max.   :1.0000   Max.   :7.000   Max.   :310.0       
##  time_spend_company Work_accident         left        promotion_last_5years
##  Min.   : 2.000     Min.   :0.0000   Min.   :0.0000   Min.   :0.00000      
##  1st Qu.: 3.000     1st Qu.:0.0000   1st Qu.:0.0000   1st Qu.:0.00000      
##  Median : 3.000     Median :0.0000   Median :0.0000   Median :0.00000      
##  Mean   : 3.498     Mean   :0.1446   Mean   :0.2381   Mean   :0.02127      
##  3rd Qu.: 4.000     3rd Qu.:0.0000   3rd Qu.:0.0000   3rd Qu.:0.00000      
##  Max.   :10.000     Max.   :1.0000   Max.   :1.0000   Max.   :1.00000      
##   Department           salary         
##  Length:14999       Length:14999      
##  Class :character   Class :character  
##  Mode  :character   Mode  :character  
##                                       
##                                       
## 

Problem 1

## 
##  Pearson's Chi-squared test
## 
## data:  table_salary_left
## X-squared = 381.23, df = 2, p-value < 2.2e-16
## # A tibble: 3 × 3
##   salary stayed   left
##   <chr>   <dbl>  <dbl>
## 1 high    0.934 0.0663
## 2 low     0.703 0.297 
## 3 medium  0.796 0.204

#The p-value is small. This suggests that there is a statistically significant relationship between salary and whether an employee leaves the company. Since the p-value is less than 0.05, we can reject the null hypothesis, which assumes that salary and attrition are independent.

#The results show that employees with lower salaries are more likely to leave the company. This suggests that salary may be an important factor affecting employee retention. Those earning less are more likely to quit than those earning more.

Problem 2

## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  table_accident_left
## X-squared = 357.56, df = 1, p-value < 2.2e-16

#The p-value is small, so we reject the null hypothesis. This means that the amount of time an employee has been with the company is significantly related to whether they leave the company. In other words, the longer someone stays at the company, the less likely they are to leave.

#Employees who have been with the company for a long time are less likely to leave. This suggests that longer tenure at the company increases the likelihood of staying, while those who have been with the company for a shorter period may be more likely to leave.

Problem 3

## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  table_promotion_left
## X-squared = 56.262, df = 1, p-value = 6.344e-14

#The p-value is small, meaning we can reject the null hypothesis. There is a significant relationship between having a work accident and leaving the company. Employees who experience work accidents are more likely to leave.

#Employees who have had a work accident are more likely to leave the company. This could mean that accidents negatively impact employee morale or job satisfaction, leading them to quit their jobs.

Problem 4

## 
##  Pearson's Chi-squared test
## 
## data:  table_department_left
## X-squared = 86.825, df = 9, p-value = 7.042e-15

#The p-value is small, so we can reject the null hypothesis. This indicates that there is a significant relationship between promotion history and whether an employee leaves the company. Employees who have received promotions are less likely to leave.

#Employees who have received promotions are more likely to stay with the company. In contrast, employees who have not received promotions are more likely to leave. This suggests that promotion opportunities play a role in keeping employees at the company.