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.
#### Task Number 1
hist(hr$satisfaction_level,
main = "Most Employees Have Moderate To Low Satisfaction Levels",
xlab = "Satisfaction Level",
col = "skyblue",
breaks = 20)

###Comments: The histogram reveals that most employees report low to moderate satisfaction levels. Very few employees report high satisfaction, suggesting possible disengagement or morale issues in the workforce.
#### Task Number 2
boxplot(hr$last_evaluation,
main = "Evaluation Scores Are Concentrated in the High Range",
ylab = "Last Evaluation Score",
col = "lightblue",
border = "black")

###Comments The box plot shows that most employees receive high evaluation scores, with very few receiving low evaluations. This suggests that employee performance is generally rated favorably across the organization.
#### Task Number 3
boxplot(average_montly_hours ~ Department, data = hr,
main = "Monthly Hours Vary Widely Across Departments",
xlab = "Department", ylab = "Average Monthly Hours",
col = rainbow(length(unique(hr$Department))),
las = 2)

#### Comments The box plot highlights that certain departments, such as IT and Technical, have higher average monthly hours compared to others. This may indicate higher workloads, which could lead to burnout or dissatisfaction.
#### Task Number 4
attrition_summary <- table(hr$salary[hr$left == 1])
pie(attrition_summary,
main = "Attrition is Highest Among Low-Salary Employees",
col = c("red", "orange", "green"))

#### Comments The pie chart shows that most employees who leave the company belong to the low-salary category. This suggests that low compensation could be a major factor contributing to employee attrition.
#### Task number 5
avg_satisfaction <- aggregate(satisfaction_level ~ Department, data = hr, mean)
barplot(
avg_satisfaction$satisfaction_level,
names.arg = avg_satisfaction$Department,
main = "Average Satisfaction Levels Vary Across Departments",
xlab = "Department",
ylab = "Average Satisfaction Level",
col = "skyblue",
las = 2 )

#### Comments The bar plot reveals that satisfaction levels vary across departments. Departments such as R&D and Technical show higher satisfaction levels, while Sales has relatively lower satisfaction, indicating potential issues in that area.