Part A

## 
## 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
## , ,  = accounting
## 
##       
##        high  low medium
##   Left    5   99    100
##   Stay   69  259    235
## 
## , ,  = hr
## 
##       
##        high  low medium
##   Left    6   92    117
##   Stay   39  243    242
## 
## , ,  = IT
## 
##       
##        high  low medium
##   Left    4  172     97
##   Stay   79  437    438
## 
## , ,  = management
## 
##       
##        high  low medium
##   Left    1   59     31
##   Stay  224  121    194
## 
## , ,  = marketing
## 
##       
##        high  low medium
##   Left    9  126     68
##   Stay   71  276    308
## 
## , ,  = product_mng
## 
##       
##        high  low medium
##   Left    6  105     87
##   Stay   62  346    296
## 
## , ,  = RandD
## 
##       
##        high  low medium
##   Left    4   55     62
##   Stay   47  309    310
## 
## , ,  = sales
## 
##       
##        high  low medium
##   Left   14  697    303
##   Stay  255 1402   1469
## 
## , ,  = support
## 
##       
##        high  low medium
##   Left    8  389    158
##   Stay  133  757    784
## 
## , ,  = technical
## 
##       
##        high  low medium
##   Left   25  378    294
##   Stay  176  994    853

Part B

Part C

Write Up

Based on the analysis, most employees who have worked in the company chose to stay. Those earning low salaries are most likely to leave across all departments. According to part B, most people who left have stayed for more than three years and currently, most people in the company only have worked for less than three years. Though people stayed outnumbered, the company may face high turnover in the next three years. Specifically, people who worked for three years and in low salary level are most likely to be leaving. Among all departments, sales, support and technical have the most employee numbers and thus have the most employees who left. Also, among high salary employees, ones in marketing and product_mng departments are most likely to leave, especially in year 3. Ones who left came from tech department as well. For those who have spent more than three years, the longer they stay, the less likely they are to be leaving.