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") %>%
layout(title = "Most Employees are Satisfied (Satisfaction > .5)",
xaxis = list(title = "Satisfaction Level"),
yaxis = list(title = "Number of Employees"))
Most Employees are Satisfied (Satisfaction > .5)
About 6% of employees are extremely dissastisfied (Satisfaction <=
.1)
plot_ly(hr, x = ~last_evaluation, type = "box") %>%
layout(title = "Last Evaluation Scores are Between 0.56 and 0.87",
xaxis = list(title = "Last Evaluation Score"),
yaxis = list(title = "Number of Evaluations"))
The median last evaluation score was a 0.72
The middle 50% of the data from number of evaluations had last
evaluation scores between 0.56 and 0.87
plot_ly(hr, x = ~Department, y = ~average_montly_hours, type = "box") %>%
layout(title = "The Median Average Monthly Hours of Employees are >= 197, maximum 204",
xaxis = list(title = "Department"),
yaxis = list(title = "Average Monthly Hours"))
The Management department has the highest median average monthly
hours of 204
The HR department has the lowest median average monthly hours of 197
salary <- hr %>%
filter(left == 1) %>%
count(salary)
plot_ly(salary, labels = ~salary, values = ~n, type = 'pie') %>%
layout(title = 'People Who Receive a Low Salary are Most Likely to Leave their Jobs')
2.3% of people who receive a high salary are likely to leave their
job
36.9% of people who receive a medium salary are likely to leave their
job
60.8% of people who receive a low salary are likely to leave their job,
so this group of people is most likely to leave their job
satisfaction_level <- hr %>%
group_by(Department) %>%
summarise(satisfaction_level = mean(satisfaction_level, na.rm = TRUE))
plot_ly(satisfaction_level, x = ~factor(Department), y =
~satisfaction_level, type = 'bar') %>%
layout(title = 'The Management Department has the Greatest Satisfaction Level of <0.62',
xaxis = list(title = 'Department'),
yaxis = list(title = 'Average Satisfaction Level'))
The Accounting department has lowest satisfaction level of 0.58
The HR department has the second lowest satisfaction level of 0.59