ggplot(HR, aes(x = satisfaction_level)) +
geom_histogram(bins = 20, fill = "steelblue", color = "white") +
labs(
title = "Employee Satisfaction Clusters at Low and High Levels",
x = "Satisfaction Level",
y = "Count"
) +
theme_minimal()
Analysis:
Satisfaction is not evenly distributed; the clustering suggests
different employee experience groups that may relate to turnover.
ggplot(HR, aes(y = last_evaluation)) +
geom_boxplot(fill = "darkorange") +
labs(
title = "Evaluation Scores Are Generally High With Few Low Outliers",
y = "Last Evaluation Score"
) +
theme_minimal()
Analysis:
Most evaluation scores are high, so attrition likely depends on factors
beyond just low performance.
ggplot(HR, aes(x = .data[[dept_col]], y = .data[[hours_col]])) +
geom_boxplot(fill = "orange") +
labs(
title = "Monthly Work Hours Differ Meaningfully Across Departments",
x = "Department",
y = "Average Monthly Hours"
) +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
Analysis:
Some departments show higher typical hours and wider variation, which
could connect to workload and burnout risk.
salary_attrition <- HR %>%
filter(left == 1) %>%
count(salary)
ggplot(salary_attrition, aes(x = "", y = n, fill = salary)) +
geom_col(width = 1, color = "white") +
coord_polar("y") +
labs(
title = "Among Employees Who Left, Lower Salary Levels Are More Common",
fill = "Salary"
) +
theme_void()
Analysis:
Within the employees who left, lower salary categories make up a larger
share, suggesting compensation relates to retention.
avg_satisfaction <- HR %>%
group_by(dept = .data[[dept_col]]) %>%
summarise(avg_sat = mean(satisfaction_level), .groups = "drop")
ggplot(avg_satisfaction, aes(x = dept, y = avg_sat)) +
geom_col(fill = "steelblue") +
labs(
title = "Average Satisfaction Varies Across Departments",
x = "Department",
y = "Average Satisfaction Level"
) +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
Analysis:
Departments with lower average satisfaction may be priority areas to
investigate for turnover and workplace improvements.