# Reading and Measuring the Data

mydata <- read.csv(paste("HR_comma_sep.csv", sep = ""))
View(mydata)
dim(mydata)
## [1] 14999    10

# Summary of the variables

library(psych)
## Warning: package 'psych' was built under R version 3.4.3
describe(mydata)
##                       vars     n   mean    sd median trimmed   mad   min
## satisfaction_level       1 14999   0.61  0.25   0.64    0.63  0.28  0.09
## last_evaluation          2 14999   0.72  0.17   0.72    0.72  0.22  0.36
## number_project           3 14999   3.80  1.23   4.00    3.74  1.48  2.00
## average_montly_hours     4 14999 201.05 49.94 200.00  200.64 65.23 96.00
## time_spend_company       5 14999   3.50  1.46   3.00    3.28  1.48  2.00
## Work_accident            6 14999   0.14  0.35   0.00    0.06  0.00  0.00
## left                     7 14999   0.24  0.43   0.00    0.17  0.00  0.00
## promotion_last_5years    8 14999   0.02  0.14   0.00    0.00  0.00  0.00
## sales*                   9 14999   6.94  2.75   8.00    7.23  2.97  1.00
## salary*                 10 14999   2.35  0.63   2.00    2.41  1.48  1.00
##                       max  range  skew kurtosis   se
## satisfaction_level      1   0.91 -0.48    -0.67 0.00
## last_evaluation         1   0.64 -0.03    -1.24 0.00
## number_project          7   5.00  0.34    -0.50 0.01
## average_montly_hours  310 214.00  0.05    -1.14 0.41
## time_spend_company     10   8.00  1.85     4.77 0.01
## Work_accident           1   1.00  2.02     2.08 0.00
## left                    1   1.00  1.23    -0.49 0.00
## promotion_last_5years   1   1.00  6.64    42.03 0.00
## sales*                 10   9.00 -0.79    -0.62 0.02
## salary*                 3   2.00 -0.42    -0.67 0.01
summary(mydata)
##  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       
##  Min.   : 2.000     Min.   :0.0000   Min.   :0.0000  
##  1st Qu.: 3.000     1st Qu.:0.0000   1st Qu.:0.0000  
##  Median : 3.000     Median :0.0000   Median :0.0000  
##  Mean   : 3.498     Mean   :0.1446   Mean   :0.2381  
##  3rd Qu.: 4.000     3rd Qu.:0.0000   3rd Qu.:0.0000  
##  Max.   :10.000     Max.   :1.0000   Max.   :1.0000  
##                                                      
##  promotion_last_5years         sales         salary    
##  Min.   :0.00000       sales      :4140   high  :1237  
##  1st Qu.:0.00000       technical  :2720   low   :7316  
##  Median :0.00000       support    :2229   medium:6446  
##  Mean   :0.02127       IT         :1227                
##  3rd Qu.:0.00000       product_mng: 902                
##  Max.   :1.00000       marketing  : 858                
##                        (Other)    :2923

# One way contingency table

table(mydata$satisfaction_level)
## 
## 0.09  0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19  0.2 0.21 0.22 0.23 
##  195  358  335   30   54   73   76   79   72   63   74   69   67   60   54 
## 0.24 0.25 0.26 0.27 0.28 0.29  0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 
##   80   34   30   30   31   38   39   59   50   36   48   37  139  241  189 
## 0.39  0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49  0.5 0.51 0.52 0.53 
##  175  209  171  155  224  211  203   95   42  149  209  229  187  196  179 
## 0.54 0.55 0.56 0.57 0.58 0.59  0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 
##  185  179  187  210  182  219  193  208  188  209  187  199  228  177  162 
## 0.69  0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79  0.8 0.81 0.82 0.83 
##  209  205  171  230  246  257  226  234  252  241  217  222  220  241  234 
## 0.84 0.85 0.86 0.87 0.88 0.89  0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 
##  247  207  200  225  187  237  220  224  198  169  167  181  203  176  183 
## 0.99    1 
##  172  111
table(mydata$last_evaluation)
## 
## 0.36 0.37 0.38 0.39  0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49  0.5 
##   22   55   50   52   57   59   56   50   44  115  211  173  292  332  353 
## 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59  0.6 0.61 0.62 0.63 0.64 0.65 
##  345  309  324  350  358  322  333  225  255  221  234  233  236  235  201 
## 0.66 0.67 0.68 0.69  0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79  0.8 
##  222  245  222  193  213  196  211  223  260  238  216  263  214  241  251 
## 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89  0.9 0.91 0.92 0.93 0.94 0.95 
##  255  237  269  294  316  273  326  235  296  313  287  269  269  263  258 
## 0.96 0.97 0.98 0.99    1 
##  249  276  263  258  283
table(mydata$average_montly_hours)
## 
##  96  97  98  99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 
##   6  14  23  11  19  16  17  17  28  17  19  10  18  18  12  26  10  29 
## 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 
##  15  14  10  18  12  10  10  24  11  20  13  19  25  72  65  63  59  69 
## 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 
## 100  87 114 153 104 122  88 120 129 115 112 127 102 134 110 118 123 148 
## 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 
## 108 147 112 122 121 125 153 126 124 121 136  87  96  73  78  78  73  94 
## 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 
##  92  86  76  83  70  96  78  76  81  81  85  73  88  78  75  84  80  93 
## 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 
##  76  68  73  85  75  80  96  67  71  67  79  70  86  79  58  86  80  72 
## 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 
##  68  73  83  71  72  72  72  79  72  71  78  68  76  87  79  85  64  81 
## 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 
##  84  93 112  95  93  77  76  93  59  77  97 102  74  76  83  90 108  96 
## 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 
##  93  85  98 112  98 124 102 108  86  93 100  98  86 101 113 115  87 126 
## 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 
## 110  98 124 102  86 110 111  91 105  88  93 102  93 104  86  88  94  82 
## 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 
##  30  21  35  32  29  34  36  25  24  33  50  30   6  19  15  17  15  13 
## 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 
##  16  12  21   7  13   6  11  24   8   6  17  18  18  14  20  16  18
table(mydata$number_project)
## 
##    2    3    4    5    6    7 
## 2388 4055 4365 2761 1174  256
table(mydata$time_spend_company)
## 
##    2    3    4    5    6    7    8   10 
## 3244 6443 2557 1473  718  188  162  214
table(mydata$left)
## 
##     0     1 
## 11428  3571
table(mydata$promotion_last_5years)
## 
##     0     1 
## 14680   319

Code 0 in table for left represents the person has not left the job while code 1 denotes he has left the job. Code 0 in table for promotion represents no promotion for the employee while code 1 denotes promotion for the employee.

# Two Way Contingency Tables

table(mydata$satisfaction_level, mydata$left)
##       
##          0   1
##   0.09   0 195
##   0.1    0 358
##   0.11   0 335
##   0.12  26   4
##   0.13  51   3
##   0.14  63  10
##   0.15  73   3
##   0.16  78   1
##   0.17  67   5
##   0.18  63   0
##   0.19  68   6
##   0.2   65   4
##   0.21  66   1
##   0.22  59   1
##   0.23  52   2
##   0.24  77   3
##   0.25  31   3
##   0.26  29   1
##   0.27  24   6
##   0.28  28   3
##   0.29  37   1
##   0.3   37   2
##   0.31  42  17
##   0.32  42   8
##   0.33  33   3
##   0.34  44   4
##   0.35  34   3
##   0.36  43  96
##   0.37  47 194
##   0.38  35 154
##   0.39  35 140
##   0.4   40 169
##   0.41  39 132
##   0.42  47 108
##   0.43  46 178
##   0.44  58 153
##   0.45  46 157
##   0.46  27  68
##   0.47  38   4
##   0.48 139  10
##   0.49 207   2
##   0.5  226   3
##   0.51 182   5
##   0.52 196   0
##   0.53 171   8
##   0.54 179   6
##   0.55 175   4
##   0.56 182   5
##   0.57 202   8
##   0.58 179   3
##   0.59 212   7
##   0.6  189   4
##   0.61 202   6
##   0.62 186   2
##   0.63 205   4
##   0.64 185   2
##   0.65 198   1
##   0.66 217  11
##   0.67 176   1
##   0.68 161   1
##   0.69 209   0
##   0.7  195  10
##   0.71 167   4
##   0.72 200  30
##   0.73 204  42
##   0.74 206  51
##   0.75 188  38
##   0.76 189  45
##   0.77 201  51
##   0.78 191  50
##   0.79 172  45
##   0.8  194  28
##   0.81 169  51
##   0.82 183  58
##   0.83 187  47
##   0.84 185  62
##   0.85 171  36
##   0.86 159  41
##   0.87 167  58
##   0.88 162  25
##   0.89 181  56
##   0.9  168  52
##   0.91 181  43
##   0.92 178  20
##   0.93 169   0
##   0.94 167   0
##   0.95 181   0
##   0.96 203   0
##   0.97 176   0
##   0.98 183   0
##   0.99 172   0
##   1    111   0

As Job satisfaction level increases number of people leaving their jobs decreases.

table(mydata$last_evaluation, mydata$left)
##       
##          0   1
##   0.36  22   0
##   0.37  55   0
##   0.38  50   0
##   0.39  52   0
##   0.4   57   0
##   0.41  59   0
##   0.42  56   0
##   0.43  50   0
##   0.44  44   0
##   0.45  50  65
##   0.46  49 162
##   0.47  60 113
##   0.48 156 136
##   0.49 219 113
##   0.5  216 137
##   0.51 216 129
##   0.52 195 114
##   0.53 203 121
##   0.54 202 148
##   0.55 248 110
##   0.56 199 123
##   0.57 210 123
##   0.58 217   8
##   0.59 249   6
##   0.6  214   7
##   0.61 232   2
##   0.62 216  17
##   0.63 233   3
##   0.64 235   0
##   0.65 194   7
##   0.66 220   2
##   0.67 239   6
##   0.68 215   7
##   0.69 193   0
##   0.7  202  11
##   0.71 188   8
##   0.72 208   3
##   0.73 220   3
##   0.74 251   9
##   0.75 229   9
##   0.76 214   2
##   0.77 218  45
##   0.78 178  36
##   0.79 197  44
##   0.8  200  51
##   0.81 206  49
##   0.82 192  45
##   0.83 181  88
##   0.84 191 103
##   0.85 219  97
##   0.86 195  78
##   0.87 197 129
##   0.88 174  61
##   0.89 211  85
##   0.9  231  82
##   0.91 216  71
##   0.92 171  98
##   0.93 174  95
##   0.94 182  81
##   0.95 177  81
##   0.96 182  67
##   0.97 192  84
##   0.98 199  64
##   0.99 192  66
##   1    116 167

Workers with higher evaluation scores have left their job which shows working/valuable employees are leaving their jobs.

table(mydata$average_montly_hours, mydata$left)
##      
##         0   1
##   96    6   0
##   97   14   0
##   98   23   0
##   99   11   0
##   100  19   0
##   101  16   0
##   102  17   0
##   103  17   0
##   104  28   0
##   105  17   0
##   106  19   0
##   107  10   0
##   108  18   0
##   109  18   0
##   110  12   0
##   111  26   0
##   112  10   0
##   113  29   0
##   114  15   0
##   115  14   0
##   116  10   0
##   117  18   0
##   118  12   0
##   119  10   0
##   120  10   0
##   121  24   0
##   122  11   0
##   123  20   0
##   124  13   0
##   125  19   0
##   126  15  10
##   127  15  57
##   128  18  47
##   129  16  47
##   130  17  42
##   131  23  46
##   132  52  48
##   133  65  22
##   134  76  38
##   135  78  75
##   136  56  48
##   137  78  44
##   138  52  36
##   139  86  34
##   140  82  47
##   141  72  43
##   142  76  36
##   143  74  53
##   144  67  35
##   145  80  54
##   146  68  42
##   147  68  50
##   148  72  51
##   149  94  54
##   150  81  27
##   151  89  58
##   152  74  38
##   153  78  44
##   154  75  46
##   155  71  54
##   156  91  62
##   157  82  44
##   158  74  50
##   159  75  46
##   160  90  46
##   161  68  19
##   162  94   2
##   163  72   1
##   164  70   8
##   165  77   1
##   166  72   1
##   167  94   0
##   168  90   2
##   169  85   1
##   170  76   0
##   171  83   0
##   172  67   3
##   173  96   0
##   174  78   0
##   175  74   2
##   176  81   0
##   177  78   3
##   178  84   1
##   179  71   2
##   180  84   4
##   181  74   4
##   182  72   3
##   183  81   3
##   184  78   2
##   185  93   0
##   186  76   0
##   187  68   0
##   188  72   1
##   189  83   2
##   190  75   0
##   191  80   0
##   192  90   6
##   193  67   0
##   194  71   0
##   195  64   3
##   196  78   1
##   197  70   0
##   198  82   4
##   199  76   3
##   200  58   0
##   201  86   0
##   202  78   2
##   203  71   1
##   204  67   1
##   205  71   2
##   206  77   6
##   207  71   0
##   208  72   0
##   209  72   0
##   210  72   0
##   211  76   3
##   212  70   2
##   213  69   2
##   214  73   5
##   215  68   0
##   216  71   5
##   217  75  12
##   218  65  14
##   219  63  22
##   220  59   5
##   221  64  17
##   222  76   8
##   223  75  18
##   224 102  10
##   225  82  13
##   226  74  19
##   227  64  13
##   228  56  20
##   229  74  19
##   230  56   3
##   231  69   8
##   232  69  28
##   233  88  14
##   234  61  13
##   235  61  15
##   236  63  20
##   237  75  15
##   238  90  18
##   239  72  24
##   240  76  17
##   241  75  10
##   242  75  23
##   243  83  29
##   244  63  35
##   245  77  47
##   246  76  26
##   247  75  33
##   248  63  23
##   249  65  28
##   250  75  25
##   251  73  25
##   252  69  17
##   253  70  31
##   254  66  47
##   255  69  46
##   256  63  24
##   257  91  35
##   258  80  30
##   259  69  29
##   260  89  35
##   261  79  23
##   262  56  30
##   263  76  34
##   264  76  35
##   265  71  20
##   266  81  24
##   267  57  31
##   268  71  22
##   269  72  30
##   270  70  23
##   271  79  25
##   272  70  16
##   273  71  17
##   274  71  23
##   275  44  38
##   276  12  18
##   277   8  13
##   278  13  22
##   279  15  17
##   280  20   9
##   281  16  18
##   282  11  25
##   283  12  13
##   284  12  12
##   285  17  16
##   286  28  22
##   287  13  17
##   288   0   6
##   289   0  19
##   290   0  15
##   291   0  17
##   292   0  15
##   293   0  13
##   294   0  16
##   295   0  12
##   296   0  21
##   297   0   7
##   298   0  13
##   299   0   6
##   300   0  11
##   301   0  24
##   302   0   8
##   303   0   6
##   304   0  17
##   305   0  18
##   306   0  18
##   307   0  14
##   308   0  20
##   309   0  16
##   310   0  18

Employees who have spent larger amount of hours in the company have left it , which shows hard working employees of the company are leaving their jobs.

table(mydata$number_project, mydata$left)
##    
##        0    1
##   2  821 1567
##   3 3983   72
##   4 3956  409
##   5 2149  612
##   6  519  655
##   7    0  256

Employees handling larger number of projects have left the company as well in large numbers.

table(mydata$time_spend_company, mydata$left)
##     
##         0    1
##   2  3191   53
##   3  4857 1586
##   4  1667  890
##   5   640  833
##   6   509  209
##   7   188    0
##   8   162    0
##   10  214    0

Those who have worked with the company for a longer time have stayed with the company.

 table(mydata$promotion_last_5years, mydata$left)
##    
##         0     1
##   0 11128  3552
##   1   300    19

Employees who haven’t been promoted have left the company in large numbers.

# Effect of satisfaction level, evaluation scores, number of projects and average monthly hours on left and not left categories

aggregate(cbind(satisfaction_level, last_evaluation, number_project, average_montly_hours) ~ left,
          data = mydata, mean)
##   left satisfaction_level last_evaluation number_project
## 1    0          0.6668096       0.7154734       3.786664
## 2    1          0.4400980       0.7181126       3.855503
##   average_montly_hours
## 1             199.0602
## 2             207.4192

My project studies that these employees who have left in such large numbers, most of them , on average are those who have a low level of satisfaction, who work for more hours and didn’t get promotion for last five years that is most of them are valuable employees who are leaving. So, I would show which of these factors pushes them the most to leave the company.

# Boxplots

Satisfaction Level

par(mar = rep(2, 4))
boxplot(satisfaction_level~left,data=mydata, main="Satisfaction level of those left", 
xlab="Satisfaction Level", ylab="Left")

we can observe that those who have left had lower satisfaction level.

Last Evaluation

boxplot(last_evaluation~left,data=mydata, main="Evaluating Scores of those left",
xlab="Last Evaluation Score", ylab="Left")

We can observe that those who have left have higher scores in last evaluation that is they are mostly good performing employees.

Number Of Projects

boxplot(number_project~left,data=mydata, main="Number of Projects of those left",
xlab="Number of Projects", ylab="Left")

Those who have left had been engaged in higher number of projects.

Average Monthly Salary

boxplot(average_montly_hours~left,data=mydata, main="Average Monthly Hours Spent by those left",
xlab="Monthly Hours Spent", ylab="Left")

Those who have left have spent more monthly hours for the company.

# Histograms

Creating a new dataframe of those employees who have left the company so that we can observe how each variable in the data affects

For satisfaction

left <- mydata[ which(mydata$left=='1') , ]
View(left)

hist(left$satisfaction_level,col="#3090C7", main = "Satisfaction level")

For Last Evaluation

hist(left$last_evaluation,col="#3090C7", main = "Last evaluation")

For Average Monthly Hours

hist(left$average_montly_hours,col="#3090C7", main = "Average montly hours")

# Plotting

We define who are the valuable employees : those who have scored lin last evaluation more than 0.6, who have worked with the company for more than 4 years and those who have completed more than 4 projects : but they have still left

library(dplyr)
## Warning: package 'dplyr' was built under R version 3.4.3
## 
## 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
goodpeopleleft <- left %>% filter(last_evaluation >= 0.60 | time_spend_company >= 4 | number_project > 4)
## Warning: package 'bindrcpp' was built under R version 3.4.3
View(goodpeopleleft)
goodpeopleleft2 <- mydata %>% filter(last_evaluation >= 0.60 | time_spend_company >= 4 | number_project > 4)
goodpeople <- goodpeopleleft2 %>% select(satisfaction_level, number_project: promotion_last_5years)
M <- cor(goodpeople)
library(corrplot)
## Warning: package 'corrplot' was built under R version 3.4.3
## corrplot 0.84 loaded
corrplot(M, method="number")

We can infer that, on average valuable employees that leave are not satisfied, work on many projects, spend many hours in the company each month and aren’t promoted.

# Corrgram

library(corrgram) 
## Warning: package 'corrgram' was built under R version 3.4.3
corrgram(mydata, order=FALSE, lower.panel=panel.shade, upper.panel=panel.pie, diag.panel=panel.minmax, text.panel=panel.txt, main="Corrgram of HR intercorrelations")

# Scatterplot Matrix

library(car)
## Warning: package 'car' was built under R version 3.4.3
## 
## Attaching package: 'car'
## The following object is masked from 'package:dplyr':
## 
##     recode
## The following object is masked from 'package:psych':
## 
##     logit
scatterplotMatrix(left[,c("satisfaction_level","last_evaluation","number_project","average_montly_hours","time_spend_company")], spread=FALSE, smoother.args=list(lty=2), main="Scatter Plot Matrix")

# Chi Square Tests

For Satisfaction level : If employees with low satisfaction leave

leftforsatisfaction <- xtabs(~ left + satisfaction_level, data=mydata)
chisq.test(leftforsatisfaction)
## 
##  Pearson's Chi-squared test
## 
## data:  leftforsatisfaction
## X-squared = 7937.7, df = 91, p-value < 2.2e-16

Since p- value is so small we can conclude that the action of leaving the jobs depends on the satisfaction level.

For Evaluation scores : If Employees with higher evaluation scores leaving the jobs

leftbyperformers <- xtabs(~ left + last_evaluation, data=mydata)
chisq.test(leftbyperformers)
## 
##  Pearson's Chi-squared test
## 
## data:  leftbyperformers
## X-squared = 2534.8, df = 64, p-value < 2.2e-16

Since p- value is so small we can conclude that the employees leaving the industry are high performers.

For Number Of Projects: Employees who have handled higher number of projects are leaving the jobs

leftonprojects <- xtabs(~ left + number_project, data=mydata)
chisq.test(leftonprojects)
## 
##  Pearson's Chi-squared test
## 
## data:  leftonprojects
## X-squared = 5373.6, df = 5, p-value < 2.2e-16

Since p- value is so small we can conclude that the employees leaving the industry have higher number of projects.

For Average monthly hours: employees working for more hours have left

leftonhours <- xtabs(~ left + average_montly_hours, data=mydata)
chisq.test(leftonhours)
## Warning in chisq.test(leftonhours): Chi-squared approximation may be
## incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  leftonhours
## X-squared = 3623.1, df = 214, p-value < 2.2e-16

Since p- value is so small we can conclude that the employees leaving the industry are those who work for more hours

For Promotion: Employees who haven’t recieved promotion have left

lefton <- xtabs(~ left + promotion_last_5years , data=mydata)
chisq.test(lefton)
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  lefton
## X-squared = 56.262, df = 1, p-value = 6.344e-14

Since p- value is so small we can conclude that the employees leaving the industry are those who haven’t recieved promotion.

# t test

t.test(leftbyperformers)
## 
##  One Sample t-test
## 
## data:  leftbyperformers
## t = 15.66, df = 129, p-value < 2.2e-16
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
##  100.7997 129.9541
## sample estimates:
## mean of x 
##  115.3769
t.test(leftforsatisfaction)
## 
##  One Sample t-test
## 
## data:  leftforsatisfaction
## t = 13.488, df = 183, p-value < 2.2e-16
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
##  69.59252 93.44009
## sample estimates:
## mean of x 
##   81.5163
t.test(lefton)
## 
##  One Sample t-test
## 
## data:  lefton
## t = 1.4496, df = 3, p-value = 0.243
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
##  -4482.527 11982.027
## sample estimates:
## mean of x 
##   3749.75

It implies with at 0.05 level of significance promotion and employees leaving or not leaving the company is independent as p- value is >0.05.

t.test(leftonhours)
## 
##  One Sample t-test
## 
## data:  leftonhours
## t = 23.274, df = 429, p-value < 2.2e-16
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
##  31.93559 37.82721
## sample estimates:
## mean of x 
##   34.8814
t.test(leftonprojects)
## 
##  One Sample t-test
## 
## data:  leftonprojects
## t = 3.0739, df = 11, p-value = 0.01059
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
##   354.9412 2144.8921
## sample estimates:
## mean of x 
##  1249.917