Justin Kaplan
Assignment 6
library(plotly)
library(readr)
library(dplyr)
HR <- read_csv('https://raw.githubusercontent.com/aiplanethub/Datasets/refs/heads/master/HR_comma_sep.csv')
Tasks
1. Histogram: Distribution of Employee Satisfaction Create a
histogram of the satisfaction_level variable. The title should reflect a
key takeaway from the distribution.
plot_ly(HR, x = ~satisfaction_level, type = "histogram") %>%
layout(title = "Most employees are generally satisfied (Satisfaction > 0.5) ",
xaxis = list(title = "Satisfaction Level"),
yaxis = list(title = "Count"))
Takeaways
- The majority of employees are satisfied which was categorized by
having a satisfaction of 0.5 or greater
- There are a large sum of employees who are very unsatisfied which
was categorized by a satisfaction of 0.2 or less
- The most common answer was a satisfaction of 0.1 which had a count
of 693 ### 2. Box Plot: Last Evaluation Scores Create a box plot of the
last_evaluation variable. The title should highlight an important
insight about the evaluation scores.
library(plotly)
plot_ly(HR, x = ~last_evaluation, type = "box") %>%
layout(title = "Most employees recieved passing evaluation grades (Evaluation Grade > 0.7) ",
xaxis = list(title = "Evaluation Grade"),
yaxis = list(title = "Count"))
Takeaways
- The median evaluation grade is 0.72
- 25% of the workers scored over a 0.87
- The minimum grade is a 0.36
- The majority of workers got a passing level grade (Evaluation grade
> 0.70)
3. Comparative Box Plot: Monthly Hours by Department Create a
comparative box plot of average_montly_hours grouped by department. The
title should emphasize a significant difference or pattern among
departments.
plot_ly(HR, x = ~as.factor(Department), y = ~average_montly_hours, type = "box") %>%
layout(title = "Departments have similar monthly hours",
xaxis = list(title = "Departments"),
yaxis = list(title = "Miles Per Gallon"))
Takeaways
- Departments generally have the same amount of hours with similar
ceilings and floors
4. Pie Chart of Frequencies: Attrition by Salary Level Create a pie
chart showing the frequency of employee attrition (left) for each salary
category. The title should point out the relationship between salary and
attrition.
Question4 <- HR %>%
filter(left == 1) %>%
count(salary)
plot_ly(Question4, labels = ~salary, values = ~n, type = 'pie') %>%
layout(title = 'Most employees that left the company had a low salary level')
Takeaways
- Most of the employees that leave the company have a low salary
- Very few of the employees that left the company had high
salaries
5. Bar Plot of Averages: Average Satisfaction by Department Create a
bar plot displaying the average satisfaction_level for each department.
The title should highlight a key observation about departmental
satisfaction.
plot_ly(HR, x = ~as.factor(Department), y = ~satisfaction_level, type = "bar") %>%
layout(title = "Sales employees have the highest level of satisfaction",
xaxis = list(title = "Departments"),
yaxis = list(title = "Satisfaction"))
Takeaways
- Sales has the highest level of satisfaction
- Management and Research and Development have thew lowest level of
satisfaction