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
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.
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 emmployees are satified (satifaction > .5)",
xaxis = list(title = "Satisfaction Level"),
yaxis = list(title = "Frequency"))
- Most employees are satisfied (satisfaction > .5)
- About 6% of employees are extremely dissatisfied ( satisfaction
level <= .1)
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.
plot_ly(hr, y = ~satisfaction_level, type = "box") %>%
layout(title = "Distribution of Satisfaction Level",
yaxis = list(title = "Level of satisfaction (satifaction > .5)"))
- median satisfaction level is .64
- Middle 50% of employees range in satisfaction level
of .44 to .82
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 = ~Department, y = ~average_montly_hours, type = "box", color = ~Department) %>%
layout(title = "Miles Per Gallon by Number of Cylinders",
xaxis = list(title = "Average Monthly Hours"),
yaxis = list(title = "Satisfaction level"))
## Warning in RColorBrewer::brewer.pal(N, "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(N, "Set2"): n too large, allowed maximum for palette Set2 is 8
## Returning the palette you asked for with that many colors
- Not much difference in medians across departments, all fall
between 197 to 204.
- There seems to be no large outliers for any of the
department.
- Based on these graphs satifaction levels seem to be fairly similar
across departments with no
one department largely more or less satisfied than the rest.
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.
plot_ly(hr, labels = ~salary, values = ~left, type = 'pie') %>%
layout(title = 'Low salary has the highest percentage attrition')
- Very small group of high salary employees with high attrition,
only 2.3 %
- Seems to be an association with salary and attrition, the higher
salaries have lower attrition
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 = ~Department, y = ~satisfaction_level, type = 'bar') %>%
layout(title = 'Sales Department is most satified',
xaxis = list(title = 'Department'),
yaxis = list(title = 'Satisfaction Level'))
- Most departments have similar levels of satisfaction except for
sales, support, and technical
- Sales have by far the most satisfaction out of all the
departments