#setup
library(readr)
library(plotly)
## Loading required package: ggplot2
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
library(dplyr)
##
## 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
hr <- read_csv('https://raw.githubusercontent.com/aiplanethub/Datasets/refs/heads/master/HR_comma_sep.csv')
## Rows: 14999 Columns: 10
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (2): Department, 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.
plot_ly(hr, x = ~satisfaction_level, type = "histogram", color = "blue") %>%
layout(title = "Most Employees Are Satisfied")
Analysis- A majority of employees have a satisfaction level above .5, there mode in the distribution is roughly .1
plot_ly(hr, y = ~last_evaluation, type = "box", color = "red") %>%
layout(title = "Evaluation Scores Vary Widely")
Analysis-A majority of evaluations are between .87 and .56
plot_ly(hr, x = ~Department, y = ~average_montly_hours, type = "box", color = ~Department) %>%
layout(title = "Management Works Most Hours")
## Warning in RColorBrewer::brewer.pal(max(N, 3L), "Set2"): n too large, allowed maximum for palette Set2 is 8
## Returning the palette you asked for with that many colors
## Warning in RColorBrewer::brewer.pal(max(N, 3L), "Set2"): n too large, allowed maximum for palette Set2 is 8
## Returning the palette you asked for with that many colors
Analysis- The boxes are mostly similar however Management has the highest median hours
left_data <- hr %>% filter(left == 1) %>% count(salary)
plot_ly(left_data, labels = ~salary, values = ~n, type = "pie") %>%
layout(title = "Lower Salary Levels Show Higher Attrition Rates")
Analysis- Low Salary has the highest attrion, while high income has the lowest. This implies that compensation is important for employee retention
avg_satisfaction <- hr %>%
group_by(Department) %>%
summarize(avg_sat = mean(satisfaction_level))
plot_ly(avg_satisfaction, x = ~Department, y = ~avg_sat, type = "bar",
marker = list(color = c('red', 'blue', 'green', 'orange', 'purple', 'pink', 'brown', 'yellow', 'gray'))) %>%
layout(title = "Management Has Highest Average Satisfaction")
Analysis- Average satisfaction rate for all departments falls close to .6, Accounting has the lowest while management has the highest