1. Histogram: Distribution of Employee Satisfaction

plot_ly(hr,
        x = ~satisfaction_level,
        type = "histogram" ,
        nbinsx = 20) %>%
  plotly::layout(title = "Most employees have moderate to high satisfaction levels",
         xaxis = list(title = "Satisfaction Level"),
         yaxis = list(title = "Count"))

2. Box Plot

plot_ly(hr,
        y = ~last_evaluation,
        type = "box") |>
  plotly::layout(
    title = "Most employees are evaluated in a narrow range with few outliers",
    yaxis = list(title = "Last Evaluation Score")
  )

Most employees are evaluated in a narrow range, with only a few very high or very low scores.

3. Comparative Box Plot: Monthly Hours by Department

plot_ly(hr,
        x = ~Department,
        y = ~average_montly_hours,
        type = "box") |>
  plotly::layout(
    title = "Some departments work more hours per month than others",
    xaxis = list(title = "Department"),
    yaxis = list(title = "Average Monthly Hours")
  )

Some departments have higher workloads and more variation in hours than others.

4.Pie Chart of Frequencies: Attrition by Salary Level

left_data <- hr |>
  dplyr::filter(left == 1) |>
  dplyr::count(salary)

plot_ly(left_data,
        labels = ~salary,
        values = ~n,
        type = "pie") |>
  plotly::layout(
    title = "Employees with low salary leave the company more often"
  )

Employees with lower salary levels appear to have higher attrition.

5.Bar Plot of Averages: Average Satisfaction by Department

avg_sat <- hr |>
  dplyr::group_by(Department) |>
  dplyr::summarise(avg_satisfaction = mean(satisfaction_level))

plot_ly(avg_sat,
        x = ~Department,
        y = ~avg_satisfaction,
        type = "bar") |>
  plotly::layout(
    title = "Some departments have higher average satisfaction than others",
    xaxis = list(title = "Department"),
    yaxis = list(title = "Average Satisfaction")
  )

Satisfaction levels vary by department, with some departments showing lower morale.