library(readr) library(plotly) library(dplyr)
Histogram: Distribution of Employee Satisfaction
plot_ly(hr, x = ~satisfaction_level, type = “histogram”) %>%
layout(title = “Satisfaction Levels Reveal Employee Engagement Trends”,
xaxis = list(title = “Satisfaction Level”), yaxis = list(title =
“Count”))
Observation:The histogram shows many employees with very low
satisfaction, suggesting widespread dissatisfaction among some. The rest
of the satisfaction levels are more evenly spread out across the
company.
Box Plot: Last Evaluation Scores
plot_ly(hr, y = ~last_evaluation, type = “box”) %>% layout(title =
“Evaluation Scores Show Consistency or Variation in Performance
Reviews”, yaxis = list(title = “Last Evaluation Score”))
Observation:The box plot shows that most employee evaluation scores
are clustered around the middle, with a median close to 0.7. There’s a
broad range of scores, from as low as 0.4 to as high as 1, indicating
variation in performance reviews.
Comparative Box Plot: Monthly Hours by Department
plot_ly(hr, x = ~Department, y = ~average_montly_hours, type = “box”)
%>% layout(title = “Monthly Hours Vary Across Departments, Indicating
Different Workloads”, xaxis = list(title = “Department”), yaxis =
list(title = “Average Monthly Hours”))
Observation:The box plot shows that the average monthly hours are
fairly consistent across all departments, with most departments having a
similar range and median around 200 hours. This suggests that workload
is relatively evenly distributed, though there is some variability
within each department.
Pie Chart of Frequencies: Attrition by Salary Level
attrition_salary <- hr %>% group_by(salary) %>%
summarise(attrition_count = sum(left == 1))
plot_ly(attrition_salary, labels = ~salary, values =
~attrition_count, type = ‘pie’) %>% layout(title = “Attrition Rates
Higher Among Low Salary Levels”)
Observation:The pie chart shows that most employee attrition occurs
among those with low salaries (60.8%), followed by medium salaries
(36.9%). Very few employees with high salaries leave the company (2.3%),
suggesting that higher pay may help reduce turnover.
Bar Plot of Averages: Average Satisfaction by Department
avg_satisfaction <- hr %>% group_by(Department) %>%
summarise(avg_satisfaction = mean(satisfaction_level))
plot_ly(avg_satisfaction, x = ~Department, y = ~avg_satisfaction,
type = ‘bar’) %>% layout(title = “Department Satisfaction Levels Show
Key Variations in Employee Morale”, xaxis = list(title = “Department”),
yaxis = list(title = “Average Satisfaction Level”))
Observation:The bar plot shows that average satisfaction levels are
fairly consistent across most departments, generally around 0.6.
However, the accounting department has a slightly lower average
satisfaction level, which may indicate lower morale in that area
compared to others.
couldn’t get the graphs knitted for some reason, tried many
different things did not work.