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.
Task 1
plot_ly(hr, x = ~satisfaction_level, type = "histogram") %>%
layout(title = "Histogram of Satisfaction Level",
xaxis = list(title = "Satisfaction Level"),
yaxis = list(title = "Frequency"))
- A majority of employyes are satisifed and have a satifaction level
about >0.5
- A group of 693 employees had a satifaction level below .11
Task 2
plot_ly(hr,
y = ~last_evaluation, type = "box") %>%
layout(title = "Histogram of Last Evaluation",
yaxis = list(title = "Last Evaluation"))
- Most of the employees evaluation scores were above .5 indicating
overall the employees did well.
- Overall the employees did well, nearly all within the same
performance level.
Task 3
plot_ly(hr, x = ~as.factor(Department), y = ~average_montly_hours, type = "box") %>%
layout(
title = "Average Monthly Hours by Department",
xaxis = list(title = "Department"),
yaxis = list(title = "Average Monthly Hours")
)
- All the departments have average monthly hours within 150 to 250
hours
- The hours for each department are relativley equal across and
consistent for all departments.
Task 4
attrition_data <- hr %>% filter (left == 1)
salary_attrition_counts <- attrition_data %>% count(salary)
plot_ly(salary_attrition_counts, labels = ~salary, values = ~n, type = 'pie') %>%
layout(title = 'Attrition by Salary Level')
- Most of employee attrition comes from low salary employees nearly
60%.
- Very few employees with high salaries leave the company.
Task 5
plot_ly(hr, x = ~Department, y = ~satisfaction_level, type = 'bar') %>%
layout(
title = 'Average Satisfaction by Department',
xaxis = list(title = 'Department'),
yaxis = list(title = 'Satisfaction Level')
)
- The sales department has the highest satisfaction for employees
- The other departments have low satisfaction with sales, support, and
technical being higher outliers.