About Pada page berikut akan dibahas tentang hubungan alasan karyawan karyawan keluar dari perusahaan.

What are some reasons why employees quit their jobs?

1. preparation data

1.1 Import Library

library(dplyr) 
library(plotly) 
library(glue)
library(scales) 
library(ggpubr) 
library(readr) 
library(tidyr) 
library(stringr)
library(rgdal)
library(leaflet)
library(sf)
library(ggplotlyExtra)
library(forcats)

1.2 Reading the file

hranalytic <- read_csv('HR_EMPLOY_AT.csv')
head(hranalytic)
#> # A tibble: 6 × 35
#>     Age Attrit…¹ Busin…² Daily…³ Depar…⁴ Dista…⁵ Educa…⁶ Educa…⁷ Emplo…⁸ Emplo…⁹
#>   <dbl> <chr>    <chr>     <dbl> <chr>     <dbl>   <dbl> <chr>     <dbl>   <dbl>
#> 1    41 Yes      Travel…    1102 Sales         1       2 Life S…       1       1
#> 2    49 No       Travel…     279 Resear…       8       1 Life S…       1       2
#> 3    37 Yes      Travel…    1373 Resear…       2       2 Other         1       4
#> 4    33 No       Travel…    1392 Resear…       3       4 Life S…       1       5
#> 5    27 No       Travel…     591 Resear…       2       1 Medical       1       7
#> 6    32 No       Travel…    1005 Resear…       2       2 Life S…       1       8
#> # … with 25 more variables: EnvironmentSatisfaction <dbl>, Gender <chr>,
#> #   HourlyRate <dbl>, JobInvolvement <dbl>, JobLevel <dbl>, JobRole <chr>,
#> #   JobSatisfaction <dbl>, MaritalStatus <chr>, MonthlyIncome <dbl>,
#> #   MonthlyRate <dbl>, NumCompaniesWorked <dbl>, Over18 <chr>, OverTime <chr>,
#> #   PercentSalaryHike <dbl>, PerformanceRating <dbl>,
#> #   RelationshipSatisfaction <dbl>, StandardHours <dbl>,
#> #   StockOptionLevel <dbl>, TotalWorkingYears <dbl>, …

1.3 Check Type Data

glimpse(hranalytic)
#> Rows: 1,470
#> Columns: 35
#> $ Age                      <dbl> 41, 49, 37, 33, 27, 32, 59, 30, 38, 36, 35, 2…
#> $ Attrition                <chr> "Yes", "No", "Yes", "No", "No", "No", "No", "…
#> $ BusinessTravel           <chr> "Travel_Rarely", "Travel_Frequently", "Travel…
#> $ DailyRate                <dbl> 1102, 279, 1373, 1392, 591, 1005, 1324, 1358,…
#> $ Department               <chr> "Sales", "Research & Development", "Research …
#> $ DistanceFromHome         <dbl> 1, 8, 2, 3, 2, 2, 3, 24, 23, 27, 16, 15, 26, …
#> $ Education                <dbl> 2, 1, 2, 4, 1, 2, 3, 1, 3, 3, 3, 2, 1, 2, 3, …
#> $ EducationField           <chr> "Life Sciences", "Life Sciences", "Other", "L…
#> $ EmployeeCount            <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, …
#> $ EmployeeNumber           <dbl> 1, 2, 4, 5, 7, 8, 10, 11, 12, 13, 14, 15, 16,…
#> $ EnvironmentSatisfaction  <dbl> 2, 3, 4, 4, 1, 4, 3, 4, 4, 3, 1, 4, 1, 2, 3, …
#> $ Gender                   <chr> "Female", "Male", "Male", "Female", "Male", "…
#> $ HourlyRate               <dbl> 94, 61, 92, 56, 40, 79, 81, 67, 44, 94, 84, 4…
#> $ JobInvolvement           <dbl> 3, 2, 2, 3, 3, 3, 4, 3, 2, 3, 4, 2, 3, 3, 2, …
#> $ JobLevel                 <dbl> 2, 2, 1, 1, 1, 1, 1, 1, 3, 2, 1, 2, 1, 1, 1, …
#> $ JobRole                  <chr> "Sales Executive", "Research Scientist", "Lab…
#> $ JobSatisfaction          <dbl> 4, 2, 3, 3, 2, 4, 1, 3, 3, 3, 2, 3, 3, 4, 3, …
#> $ MaritalStatus            <chr> "Single", "Married", "Single", "Married", "Ma…
#> $ MonthlyIncome            <dbl> 5993, 5130, 2090, 2909, 3468, 3068, 2670, 269…
#> $ MonthlyRate              <dbl> 19479, 24907, 2396, 23159, 16632, 11864, 9964…
#> $ NumCompaniesWorked       <dbl> 8, 1, 6, 1, 9, 0, 4, 1, 0, 6, 0, 0, 1, 0, 5, …
#> $ Over18                   <chr> "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", …
#> $ OverTime                 <chr> "Yes", "No", "Yes", "Yes", "No", "No", "Yes",…
#> $ PercentSalaryHike        <dbl> 11, 23, 15, 11, 12, 13, 20, 22, 21, 13, 13, 1…
#> $ PerformanceRating        <dbl> 3, 4, 3, 3, 3, 3, 4, 4, 4, 3, 3, 3, 3, 3, 3, …
#> $ RelationshipSatisfaction <dbl> 1, 4, 2, 3, 4, 3, 1, 2, 2, 2, 3, 4, 4, 3, 2, …
#> $ StandardHours            <dbl> 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 8…
#> $ StockOptionLevel         <dbl> 0, 1, 0, 0, 1, 0, 3, 1, 0, 2, 1, 0, 1, 1, 0, …
#> $ TotalWorkingYears        <dbl> 8, 10, 7, 8, 6, 8, 12, 1, 10, 17, 6, 10, 5, 3…
#> $ TrainingTimesLastYear    <dbl> 0, 3, 3, 3, 3, 2, 3, 2, 2, 3, 5, 3, 1, 2, 4, …
#> $ WorkLifeBalance          <dbl> 1, 3, 3, 3, 3, 2, 2, 3, 3, 2, 3, 3, 2, 3, 3, …
#> $ YearsAtCompany           <dbl> 6, 10, 0, 8, 2, 7, 1, 1, 9, 7, 5, 9, 5, 2, 4,…
#> $ YearsInCurrentRole       <dbl> 4, 7, 0, 7, 2, 7, 0, 0, 7, 7, 4, 5, 2, 2, 2, …
#> $ YearsSinceLastPromotion  <dbl> 0, 1, 0, 3, 2, 3, 0, 0, 1, 7, 0, 0, 4, 1, 0, …
#> $ YearsWithCurrManager     <dbl> 5, 7, 0, 0, 2, 6, 0, 0, 8, 7, 3, 8, 3, 2, 3, …

1.4 Convert Type Data

hranalytic <- hranalytic %>% 
  mutate(
    Attrition = as_factor(Attrition),
    BusinessTravel = as_factor(BusinessTravel),
    Department = as_factor(Department),
    EducationField = as_factor(EducationField),
    Gender = as_factor(Gender),
    JobRole = as_factor(JobRole),
    MaritalStatus = as_factor(MaritalStatus),
    Over18 = as_factor(Over18),
    OverTime = as_factor(OverTime)
  )
glimpse(hranalytic)
#> Rows: 1,470
#> Columns: 35
#> $ Age                      <dbl> 41, 49, 37, 33, 27, 32, 59, 30, 38, 36, 35, 2…
#> $ Attrition                <fct> Yes, No, Yes, No, No, No, No, No, No, No, No,…
#> $ BusinessTravel           <fct> Travel_Rarely, Travel_Frequently, Travel_Rare…
#> $ DailyRate                <dbl> 1102, 279, 1373, 1392, 591, 1005, 1324, 1358,…
#> $ Department               <fct> Sales, Research & Development, Research & Dev…
#> $ DistanceFromHome         <dbl> 1, 8, 2, 3, 2, 2, 3, 24, 23, 27, 16, 15, 26, …
#> $ Education                <dbl> 2, 1, 2, 4, 1, 2, 3, 1, 3, 3, 3, 2, 1, 2, 3, …
#> $ EducationField           <fct> Life Sciences, Life Sciences, Other, Life Sci…
#> $ EmployeeCount            <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, …
#> $ EmployeeNumber           <dbl> 1, 2, 4, 5, 7, 8, 10, 11, 12, 13, 14, 15, 16,…
#> $ EnvironmentSatisfaction  <dbl> 2, 3, 4, 4, 1, 4, 3, 4, 4, 3, 1, 4, 1, 2, 3, …
#> $ Gender                   <fct> Female, Male, Male, Female, Male, Male, Femal…
#> $ HourlyRate               <dbl> 94, 61, 92, 56, 40, 79, 81, 67, 44, 94, 84, 4…
#> $ JobInvolvement           <dbl> 3, 2, 2, 3, 3, 3, 4, 3, 2, 3, 4, 2, 3, 3, 2, …
#> $ JobLevel                 <dbl> 2, 2, 1, 1, 1, 1, 1, 1, 3, 2, 1, 2, 1, 1, 1, …
#> $ JobRole                  <fct> Sales Executive, Research Scientist, Laborato…
#> $ JobSatisfaction          <dbl> 4, 2, 3, 3, 2, 4, 1, 3, 3, 3, 2, 3, 3, 4, 3, …
#> $ MaritalStatus            <fct> Single, Married, Single, Married, Married, Si…
#> $ MonthlyIncome            <dbl> 5993, 5130, 2090, 2909, 3468, 3068, 2670, 269…
#> $ MonthlyRate              <dbl> 19479, 24907, 2396, 23159, 16632, 11864, 9964…
#> $ NumCompaniesWorked       <dbl> 8, 1, 6, 1, 9, 0, 4, 1, 0, 6, 0, 0, 1, 0, 5, …
#> $ Over18                   <fct> Y, Y, Y, Y, Y, Y, Y, Y, Y, Y, Y, Y, Y, Y, Y, …
#> $ OverTime                 <fct> Yes, No, Yes, Yes, No, No, Yes, No, No, No, N…
#> $ PercentSalaryHike        <dbl> 11, 23, 15, 11, 12, 13, 20, 22, 21, 13, 13, 1…
#> $ PerformanceRating        <dbl> 3, 4, 3, 3, 3, 3, 4, 4, 4, 3, 3, 3, 3, 3, 3, …
#> $ RelationshipSatisfaction <dbl> 1, 4, 2, 3, 4, 3, 1, 2, 2, 2, 3, 4, 4, 3, 2, …
#> $ StandardHours            <dbl> 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 8…
#> $ StockOptionLevel         <dbl> 0, 1, 0, 0, 1, 0, 3, 1, 0, 2, 1, 0, 1, 1, 0, …
#> $ TotalWorkingYears        <dbl> 8, 10, 7, 8, 6, 8, 12, 1, 10, 17, 6, 10, 5, 3…
#> $ TrainingTimesLastYear    <dbl> 0, 3, 3, 3, 3, 2, 3, 2, 2, 3, 5, 3, 1, 2, 4, …
#> $ WorkLifeBalance          <dbl> 1, 3, 3, 3, 3, 2, 2, 3, 3, 2, 3, 3, 2, 3, 3, …
#> $ YearsAtCompany           <dbl> 6, 10, 0, 8, 2, 7, 1, 1, 9, 7, 5, 9, 5, 2, 4,…
#> $ YearsInCurrentRole       <dbl> 4, 7, 0, 7, 2, 7, 0, 0, 7, 7, 4, 5, 2, 2, 2, …
#> $ YearsSinceLastPromotion  <dbl> 0, 1, 0, 3, 2, 3, 0, 0, 1, 7, 0, 0, 4, 1, 0, …
#> $ YearsWithCurrManager     <dbl> 5, 7, 0, 0, 2, 6, 0, 0, 8, 7, 3, 8, 3, 2, 3, …
  1. Check null data
# Check for empty or missing data in each column
colSums(is.na(hranalytic))
#>                      Age                Attrition           BusinessTravel 
#>                        0                        0                        0 
#>                DailyRate               Department         DistanceFromHome 
#>                        0                        0                        0 
#>                Education           EducationField            EmployeeCount 
#>                        0                        0                        0 
#>           EmployeeNumber  EnvironmentSatisfaction                   Gender 
#>                        0                        0                        0 
#>               HourlyRate           JobInvolvement                 JobLevel 
#>                        0                        0                        0 
#>                  JobRole          JobSatisfaction            MaritalStatus 
#>                        0                        0                        0 
#>            MonthlyIncome              MonthlyRate       NumCompaniesWorked 
#>                        0                        0                        0 
#>                   Over18                 OverTime        PercentSalaryHike 
#>                        0                        0                        0 
#>        PerformanceRating RelationshipSatisfaction            StandardHours 
#>                        0                        0                        0 
#>         StockOptionLevel        TotalWorkingYears    TrainingTimesLastYear 
#>                        0                        0                        0 
#>          WorkLifeBalance           YearsAtCompany       YearsInCurrentRole 
#>                        0                        0                        0 
#>  YearsSinceLastPromotion     YearsWithCurrManager 
#>                        0                        0

2. Analytics

2.1 How is attrition dependent on Gender

options(repr.plot.width=8, repr.plot.height=4)

attritions_number <- hranalytic %>% group_by(Attrition) %>% summarise(Count=n()) %>%
ggplot(aes(x=Attrition, y=Count)) + geom_bar(stat="identity", fill="orange", color="grey40") + theme_bw() + coord_flip() + 
geom_text(aes(x=Attrition, y=0.01, label= Count),
            hjust=-0.8, vjust=-1, size=3, 
            colour="black", fontface="bold",
         angle=360) + labs(title="Employee Attrition (Amount)", x="Employee Attrition",y="Amount") + theme(plot.title=element_text(hjust=0.5))

attrition_percentage <- hranalytic %>% group_by(Attrition) %>% summarise(Count=n()) %>% 
mutate(pct=round(prop.table(Count),2) * 100) %>% 
ggplot(aes(x=Attrition, y=pct)) + geom_bar(stat="identity", fill = "dodgerblue", color="grey40") + 
geom_text(aes(x=Attrition, y=0.01, label= sprintf("%.2f%%", pct)),
            hjust=0.5, vjust=-3, size=4, 
            colour="black", fontface="bold") + theme_bw() + labs(x="Employee Attrition", y="Percentage") + 
labs(title="Employee Attrition (%)") + theme(plot.title=element_text(hjust=0.5))

attritions_number

attrition_percentage

Insight • Usia: Rata-rata usia perempuan adalah 37,33 dan laki-laki adalah 36,65 . • Kepuasan Kerja: Perempuan memiliki tingkat kepuasan yang lebih rendah dibandingkan dengan laki-laki. • Gaji: Gaji rata-rata untuk kedua jenis kelamin hampir sama dengan laki-laki menghasilkan rata-rata 6380,51 dan perempuan 6686,57. • Departemen: Ada lebih banyak laki-laki di ketiga departemen tersebut, namun perempuan lebih dominan di departemen Penelitian dan Pengembangan.

2.2 How is attrition dependent on Age ?

# Menghitung jumlah orang berdasarkan usia dan status attrition
age_att <- hranalytic %>%
  group_by(Age, Attrition) %>%
  summarise(Counts = n()) %>%
  ungroup()

# Membuat plot garis menggunakan plotly
fig <- plot_ly(age_att, x = ~Age, y = ~Counts, color = ~Attrition, type = "scatter", mode = "lines",
               line = list(width = 2)) %>%
  layout(title = "Agewise Counts of People in an Organization",
         xaxis = list(title = "Age"),
         yaxis = list(title = "Counts"))

# Menampilkan plot
fig

Insight Pada usia 21, organisasi memiliki tingkat kestabilan karyawan yang tinggi, karena tingkat resign dan bertahannya karyawan hampir sama. Namun, pada usia yang lebih muda seperti 18-20, karyawan resign dari organisasi jauh lebih tinggi, sedangkan pada usia 28-32 terjadi peningkatan signifikan dalam tingkat resign karyawan. Setelah itu, tingkat resign karyawan cenderung menurun seiring bertambahnya usia.

2.2 Is income the main factor towards employee attrition ?

rate_att <- hranalytic %>%
  group_by(MonthlyIncome, Attrition) %>%
  summarise(Counts = n()) %>%
  mutate(MonthlyIncome = round(MonthlyIncome, -3)) %>%
  group_by(MonthlyIncome, Attrition) %>%
  summarise(Counts = sum(Counts))

fig <- rate_att %>%
  ggplot(aes(x = MonthlyIncome, y = Counts, color = Attrition)) +
  geom_line() +
  ggtitle("Monthly Income basis counts of People in an Organization")

fig <- ggplotly(fig)
fig

Insight Grafik diatas menunjukan ketika income perbulan dibawah 5000, menjadi kelas dimana jumlah tertinggi karyawan resign. Kemudian grafik jumlah karyawan resign menunjukan penurunan seiring bertambahnya income perbulan..

2.2 Does the Department of work impact attrition?

dept_att <- hranalytic %>%
  group_by(Department, Attrition) %>%
  summarize(Counts = n()) %>%
  ungroup() 

fig <- plot_ly(dept_att, x = ~Department, y = ~Counts, color = ~Attrition, type = 'bar', 
               name = ~Attrition, text = ~Counts, textposition = 'auto',
               hovertemplate = 'Department: %{x}<br>Counts: %{y}') %>%
  layout(title = 'Department wise Counts of People in an Organization',  barmode = 'stack',
         xaxis = list(title = 'Department'),
         yaxis = list(title = 'Counts'))




fig

Insight Departemen Sales memiliki tingkat attrisi tertinggi (25,84%), diikuti oleh Departemen Sumber Daya Manusia (19,05%). Penelitian dan Pengembangan memiliki tingkat attrisi paling rendah, yang menunjukkan stabilitas dan kepuasan di departemen tersebut seperti yang dapat dilihat dari grafik di atas (13,83%).

2.3 How does the environment satisfaction impact attrition?

sats_att <- hranalytic %>% 
  group_by(EnvironmentSatisfaction, Attrition) %>% 
  summarize(Counts = n()) %>% 
  ungroup()

fig <- plot_ly(sats_att, x = ~EnvironmentSatisfaction, y = ~Counts, color = ~Attrition, 
               type = 'scatter', mode = 'bar', fill = 'tozeroy', 
               line = list(width = 0.5), 
               hovertemplate = 'Environment Satisfaction: %{x}<br>Counts: %{y}') %>% 
  layout(title = 'Environment Satisfaction level Counts of People in an Organization',
         barmode = 'stack',
         xaxis = list(title = 'Environment Satisfaction level'),
         yaxis = list(title = 'Counts'))

fig

Insight Dalam mengamati tingkat kepuasan, ditemukan bahwa pada level kepuasan 1-2, kemungkinan seseorang untuk meninggalkan perusahaan sedikit menurun. Hal ini menunjukkan bahwa orang memiliki harapan yang lebih baik dan oleh karena itu memilih untuk tetap tinggal dalam perusahaan. Namun, ketika tingkat kepuasan bergerak dari 2 ke 3, orang cenderung pindah untuk mencari peluang dan pengalaman yang lebih baik.

2.4 How does self Job Satisfaction impact the Attrition?

jsats_att <- hranalytic %>% 
  group_by(JobSatisfaction, Attrition) %>% 
  summarize(Counts = n()) %>% 
  ungroup()

fig <- plot_ly(jsats_att, x = ~JobSatisfaction, y = ~Counts, color = ~Attrition,
               
type = 'scatter', mode = 'bar', fill = 'tozeroy', 
               line = list(width = 0.5), 
               hovertemplate = 'Job Satisfaction: %{x}<br>Counts: %{y}') %>% 
  layout( title = "Job Satisfaction level Counts of People in an Organization",
         barmode = 'stack',
         xaxis = list(title = 'Environment Satisfaction level'),
         yaxis = list(title = 'Counts'))


fig

Insight semakin tinggi tingkat kepuasan kerja, maka tingkat turnover (mutasi karyawan) menurun, seperti yang terlihat pada grafik di atas. Selain itu, seperti yang terlihat pada Environment Satisfaction di atas, tingkat turnover juga menurun pada rentang 1-2, namun meningkat dari 2-3, di mana orang cenderung memilih peluang yang lebih baik.

2.5 Does company stocks for employees impact attrition?

# Group and count data
stock_att <- hranalytic %>% 
  group_by(StockOptionLevel, Attrition) %>% 
  summarise(Counts = n()) %>% 
  ungroup()

# Create plot
fig <- plot_ly(stock_att, x = ~StockOptionLevel, y = ~Counts, color = ~Attrition, type = "bar") %>%
  layout(title = "Stock facilities level wise People in an Organization",
         xaxis = list(title = "Stock facilities level"),
         yaxis = list(title = "Count"),
         legend = list(title = "Attrition", x = 0.5, y = 1)) 
  
# Show plot
fig

Insight Tingkat ketersediaan opsi saham perusahaan untuk karyawan dapat memengaruhi tingkat turnover di organisasi. Karyawan yang memiliki opsi saham yang sangat terbatas atau bahkan tidak sama sekali cenderung memiliki kebebasan untuk meninggalkan organisasi dengan mudah, sementara karyawan dengan opsi saham yang lebih besar mungkin lebih terikat pada organisasi karena mereka tidak ingin kehilangan kesempatan besar untuk penghasilan di masa depan.

2.6 Work Life Balance

library(dplyr)
library(plotly)

wlb_att <- hranalytic %>% 
  group_by(WorkLifeBalance, Attrition) %>% 
  summarize(Counts = n()) %>% 
  ungroup()

wlb_att_perc <- wlb_att %>%
  group_by(WorkLifeBalance) %>%
  mutate(Attrition_pct = Counts / sum(Counts)) %>%
  ungroup()

wlb_att_perc$Attrition_pct <- ifelse(wlb_att_perc$Attrition == "Yes",
                                     paste0(round(wlb_att_perc$Attrition_pct * 100, 2), "% Yes"),
                                     paste0(round(wlb_att_perc$Attrition_pct * 100, 2), "% No"))

plot_ly(wlb_att_perc, x = ~WorkLifeBalance, y = ~Counts, color = ~Attrition, type = "bar", 
        text = ~paste("WorkLifeBalance: ", WorkLifeBalance, "<br>Attrition: ", Attrition, "<br>Counts: ", Counts, "<br>Percentage: ", Attrition_pct),
        marker = list(hoverinfo = "text")) %>% 
  layout(title = "Work Life Balance level Counts of People in an Organization", 
         xaxis = list(title = "Work Life Balance"), yaxis = list(title = "Counts"))

Insight Orang-orang dengan tingkat keseimbangan hidup kerja yang buruk telah menyesuaikan diri dengan pekerjaan mereka, tetapi seperti yang terlihat pada parameter di atas dengan skor keseimbangan hidup yang lebih baik, orang-orang lebih terbiasa dengan kehidupan yang lebih baik dan ingin pindah pekerjaan lebih banyak. Namun, tren ini hilang ketika keseimbangan hidup kerja benar-benar baik, dan orang-orang merasa puas dengan pekerjaan yang mereka lakukan.

2.7 Work Experience

library(dplyr)
library(plotly)

ncwrd_att <- hranalytic %>%
  group_by(NumCompaniesWorked, Attrition) %>%
  summarize(Counts = n()) %>%
  ungroup()

plot_ly(ncwrd_att, x = ~NumCompaniesWorked, y = ~Counts, color = ~Attrition, type = "scatter", mode = "lines", fill = "tozeroy", 
        line = list(shape = "spline"), 
        text = ~paste("NumCompaniesWorked: ", NumCompaniesWorked, "<br>Attrition: ", Attrition, "<br>Counts: ", Counts),
        marker = list(hoverinfo = "text")) %>% 
  layout(title = "Work Experience level Counts of People in an Organization", 
         xaxis = list(title = "Number of Companies Worked"), yaxis = list(title = "Counts"))

Insight

Seperti yang terlihat dari grafik di atas, jelas bahwa karyawan yang memulai karir mereka dengan perusahaan - atau telah beralih ke perusahaan di awal tahun-tahun karir mereka, memiliki peluang yang lebih tinggi untuk meninggalkan perusahaan ke perusahaan lain. Orang-orang yang telah memperoleh banyak pengalaman - bekerja di banyak perusahaan cenderung tinggal di perusahaan tempat mereka bergabung.

2.8 Work duration in current role

yrscr_att <- hranalytic %>%
  group_by(YearsInCurrentRole,Attrition)%>%
                        summarize(Counts= n())%>%
  ungroup()

plot_ly(yrscr_att, x = ~YearsInCurrentRole, y = ~Counts, color = ~Attrition, type = "scatter", mode = "lines",
        line = list(shape = "spline"),
        text = ~paste("YearsInCurrentRole: ", YearsInCurrentRole, "<br>Attrition: ", Attrition, "<br>Counts: ", Counts),
        marker = list(hoverinfo = "text")) %>% 
  layout(title = "Counts of People working for years in an Organization",
         xaxis = list(title = "Years In Current Role"), yaxis = list(title = "Counts"))

Insight Orang cenderung lebih sering meninggalkan perusahaan pada tahun-tahun awal dalam peran mereka. Ketika orang berada dalam peran yang sama untuk waktu yang lama, mereka cenderung bertahan lebih lama untuk bergerak ke peran yang lebih tinggi.

2.8 Factor Manager

man_att <- hranalytic %>%
  group_by(YearsWithCurrManager, Attrition) %>%
  summarize(Counts = n()) %>%
  ungroup()

plot <- man_att %>%
  plot_ly(x = ~YearsWithCurrManager, y = ~Counts, color = ~Attrition, type = 'scatter', mode = 'lines') %>%
  layout(title = "Count of people spending years with a Manager in an Organization",
         xaxis = list(title = "Years with Current Manager"),
         yaxis = list(title = "Count"),
         hovermode = 'closest') %>%
  add_trace(text = ~paste("Attrition: ", Attrition, "<br>",
                          "Years with Current Manager: ", YearsWithCurrManager, "<br>",
                          "Count: ", Counts, "<br>"),
            hoverinfo = 'text')

plot

Insight Grafik diatas menunjukan lonjakan besar dalam tingkat pergantian karyawan ketika berada ditahun 1-4, dan terjadi lonjakan lagi di tahun ke 7-8 setelah itu turun seiring bertamabahnya tahun.


3. Summary

  1. Orang cenderung beralih ke pekerjaan yang berbeda pada awal karir.
  2. Gaji yang lebih tinggi membuat lebih banyak karyawan tetap pada perusahaan.
  3. Karyawan dengan standar Keseimbangan kerja dan kehidupan tinggi cenderung pindah mencari peluang yang lebih baik.
  4. Departemen mempengaruhi tingkat keluarnya karyawan misal departemen penjualan memiliki persentase lebih besar untuk meninggalkan perusaha.