library(readr)
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.
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
plot_ly(hr, x = ~satisfaction_level, type = "histogram") %>%
layout(title = "Most Employees Have Moderate to High Satisfaction Levels",
xaxis = list(title = "Employee Satisfaction Level"),
yaxis = list(title = "Number of Employees"))
The histogram shows that most employees report moderate to high satisfaction levels (around 0.5–0.9), indicating generally positive morale across the organization.However, the right-skewed distribution reveals a smaller group with very low satisfaction near 0.1, suggesting a potential risk of disengagement or turnover among these employees.Addressing the factors contributing to low satisfaction could further strengthen overall employee well-being and retention.
plot_ly(hr, x = ~last_evaluation, type = "box") %>%
layout(title = "Employee Evaluation Scores Are Generally High with Few Low Outliers",
yaxis = list(title = "Last Evaluation Score"))
The box plot shows that most employees receive high evaluation scores between 0.6 and 0.8, indicating strong overall performance across the organization. Only a few low outliers appear, suggesting a small group of employees who may need additional performance support. Overall, the data reflect a largely effective and capable workforce.
plot_ly(hr, x = ~Department, y = ~average_montly_hours, type = "box") %>%
layout(
title = "Average Monthly Hours Are Consistent Across Departments With Only Very Small Differences in Department Averages",
xaxis = list(title = "Department"),
yaxis = list(title = "Average Monthly Hours"))
Employees across all departments work a similar number of hours per month, indicating a well-balanced workload distribution throughout the organization. This consistency suggests fair scheduling practices and effective resource management. However, further evaluation of task complexity and stress levels could help ensure that balance in hours also reflects balance in overall job demands.
salary_attrition <- hr %>%
filter(left == 1) %>%
dplyr::count(salary)
plot_ly(salary_attrition, labels = ~salary, values = ~n, type = 'pie') %>%
layout(title = 'Employees That Have Lower Salaries Tend to Have Higher Attrition')
The data revealed a clear relationship between salary level and employee attrition. Employees earning lower salaries are significantly more likely to leave the company compared to those in the medium or high salary categories. This pattern suggests that compensation plays a critical role in employee retention which could be because lower paid employees may experience higher financial stress, feel undervalued, or perceive limited opportunities for advancement. On the other side, employees with higher salaries tend to remain with the company longer, which could reflect greater job satisfaction, stronger organizational commitment, or the presence of roles that offer more stability and recognition.
avg_satisfaction <- hr %>%
group_by(Department) %>%
summarise(avg_satisfaction = mean(satisfaction_level, na.rm = TRUE))
plot_ly(avg_satisfaction, x = ~Department, y = ~avg_satisfaction, type = 'bar') %>%
layout(title = 'Satisfaction Levels Vary Across Departments But Are Very Similar',
xaxis = list(title = 'Department'),
yaxis = list(title = 'Average Satisfaction Level'))
The bar plot shows the average satisfaction level for each department within the company. Most departments have very similar satisfaction levels with only the Accounting department having a noticeably low satisfaction level. This suggests that employee experience and engagement vary significantly across departments, which could be influenced by factors such as management style, workload, or team dynamics. Identifying departments with lower satisfaction can help target interventions to improve overall employee morale and reduce attrition.