R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

# Install and load necessary libraries

library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.4     ✔ tibble    3.2.1
## ✔ lubridate 1.9.2     ✔ tidyr     1.3.0
## ✔ purrr     1.0.2     
## ── 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
library(corrplot)
## corrplot 0.92 loaded
# 1. Create a Box Plot for employee satisfaction and last evaluation, each broken out by the
 #variable left. This meaning that for each variable there will be two box plots, side by side,
#where each box will represent the same variable, but one filtered for left = 0, and the other
#left = 1.


# Read data from CSV file
emp_data <- read_csv("HR_comma_sep-1.csv")
## Rows: 14999 Columns: 10
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (2): sales, 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.

Including Plots

## $corr
##                       satisfaction_level last_evaluation number_project
## satisfaction_level            1.00000000     0.105021214   -0.142969586
## last_evaluation               0.10502121     1.000000000    0.349332589
## number_project               -0.14296959     0.349332589    1.000000000
## average_montly_hours         -0.02004811     0.339741800    0.417210634
## time_spend_company           -0.10086607     0.131590722    0.196785891
## Work_accident                 0.05869724    -0.007104289   -0.004740548
## left                         -0.38837498     0.006567120    0.023787185
## promotion_last_5years         0.02560519    -0.008683768   -0.006063958
##                       average_montly_hours time_spend_company Work_accident
## satisfaction_level            -0.020048113       -0.100866073   0.058697241
## last_evaluation                0.339741800        0.131590722  -0.007104289
## number_project                 0.417210634        0.196785891  -0.004740548
## average_montly_hours           1.000000000        0.127754910  -0.010142888
## time_spend_company             0.127754910        1.000000000   0.002120418
## Work_accident                 -0.010142888        0.002120418   1.000000000
## left                           0.071287179        0.144822175  -0.154621634
## promotion_last_5years         -0.003544414        0.067432925   0.039245435
##                              left promotion_last_5years
## satisfaction_level    -0.38837498           0.025605186
## last_evaluation        0.00656712          -0.008683768
## number_project         0.02378719          -0.006063958
## average_montly_hours   0.07128718          -0.003544414
## time_spend_company     0.14482217           0.067432925
## Work_accident         -0.15462163           0.039245435
## left                   1.00000000          -0.061788107
## promotion_last_5years -0.06178811           1.000000000
## 
## $corrPos
##                    xName                 yName x y         corr
## 1     satisfaction_level    satisfaction_level 1 8  1.000000000
## 2     satisfaction_level       last_evaluation 1 7  0.105021214
## 3     satisfaction_level        number_project 1 6 -0.142969586
## 4     satisfaction_level  average_montly_hours 1 5 -0.020048113
## 5     satisfaction_level    time_spend_company 1 4 -0.100866073
## 6     satisfaction_level         Work_accident 1 3  0.058697241
## 7     satisfaction_level                  left 1 2 -0.388374983
## 8     satisfaction_level promotion_last_5years 1 1  0.025605186
## 9        last_evaluation    satisfaction_level 2 8  0.105021214
## 10       last_evaluation       last_evaluation 2 7  1.000000000
## 11       last_evaluation        number_project 2 6  0.349332589
## 12       last_evaluation  average_montly_hours 2 5  0.339741800
## 13       last_evaluation    time_spend_company 2 4  0.131590722
## 14       last_evaluation         Work_accident 2 3 -0.007104289
## 15       last_evaluation                  left 2 2  0.006567120
## 16       last_evaluation promotion_last_5years 2 1 -0.008683768
## 17        number_project    satisfaction_level 3 8 -0.142969586
## 18        number_project       last_evaluation 3 7  0.349332589
## 19        number_project        number_project 3 6  1.000000000
## 20        number_project  average_montly_hours 3 5  0.417210634
## 21        number_project    time_spend_company 3 4  0.196785891
## 22        number_project         Work_accident 3 3 -0.004740548
## 23        number_project                  left 3 2  0.023787185
## 24        number_project promotion_last_5years 3 1 -0.006063958
## 25  average_montly_hours    satisfaction_level 4 8 -0.020048113
## 26  average_montly_hours       last_evaluation 4 7  0.339741800
## 27  average_montly_hours        number_project 4 6  0.417210634
## 28  average_montly_hours  average_montly_hours 4 5  1.000000000
## 29  average_montly_hours    time_spend_company 4 4  0.127754910
## 30  average_montly_hours         Work_accident 4 3 -0.010142888
## 31  average_montly_hours                  left 4 2  0.071287179
## 32  average_montly_hours promotion_last_5years 4 1 -0.003544414
## 33    time_spend_company    satisfaction_level 5 8 -0.100866073
## 34    time_spend_company       last_evaluation 5 7  0.131590722
## 35    time_spend_company        number_project 5 6  0.196785891
## 36    time_spend_company  average_montly_hours 5 5  0.127754910
## 37    time_spend_company    time_spend_company 5 4  1.000000000
## 38    time_spend_company         Work_accident 5 3  0.002120418
## 39    time_spend_company                  left 5 2  0.144822175
## 40    time_spend_company promotion_last_5years 5 1  0.067432925
## 41         Work_accident    satisfaction_level 6 8  0.058697241
## 42         Work_accident       last_evaluation 6 7 -0.007104289
## 43         Work_accident        number_project 6 6 -0.004740548
## 44         Work_accident  average_montly_hours 6 5 -0.010142888
## 45         Work_accident    time_spend_company 6 4  0.002120418
## 46         Work_accident         Work_accident 6 3  1.000000000
## 47         Work_accident                  left 6 2 -0.154621634
## 48         Work_accident promotion_last_5years 6 1  0.039245435
## 49                  left    satisfaction_level 7 8 -0.388374983
## 50                  left       last_evaluation 7 7  0.006567120
## 51                  left        number_project 7 6  0.023787185
## 52                  left  average_montly_hours 7 5  0.071287179
## 53                  left    time_spend_company 7 4  0.144822175
## 54                  left         Work_accident 7 3 -0.154621634
## 55                  left                  left 7 2  1.000000000
## 56                  left promotion_last_5years 7 1 -0.061788107
## 57 promotion_last_5years    satisfaction_level 8 8  0.025605186
## 58 promotion_last_5years       last_evaluation 8 7 -0.008683768
## 59 promotion_last_5years        number_project 8 6 -0.006063958
## 60 promotion_last_5years  average_montly_hours 8 5 -0.003544414
## 61 promotion_last_5years    time_spend_company 8 4  0.067432925
## 62 promotion_last_5years         Work_accident 8 3  0.039245435
## 63 promotion_last_5years                  left 8 2 -0.061788107
## 64 promotion_last_5years promotion_last_5years 8 1  1.000000000
## 
## $arg
## $arg$type
## [1] "full"

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.