#q1

plot_ly(hr, x = ~satisfaction_level, type = "histogram") %>%
  layout(title = "Distribution of Employee Satisfaction",
         xaxis = list(title = "Satisfaction Level"),
         yaxis = list(title = "Count"))

#q2

plot_ly(hr, y = ~last_evaluation, type = "box") %>%
  layout(title = "Distribution of Last Evaluation Scores: Insights into Performance Spread",
         yaxis = list(title = "Last Evaluation Scores"))
#most employees have evaluations between 0.6 and 0.9 with a few outliers but most are moderate

#q3

plot_ly(hr, x = ~Department, y = ~average_montly_hours, type = "box") %>%
  layout(title = "Average Monthly Hours by Department: Differences in Workload",
         xaxis = list(title = "Department"),
         yaxis = list(title = "Average Monthly Hours"))

#4

salary_attrition_counts <- hr %>%
  count(salary)
pie_chart <- plot_ly(salary_attrition_counts, labels = ~salary, values = ~n, type = 'pie') %>%
  layout(title = 'Attrition by Salary Level: Higher Attrition in Lower Salary Brackets')

#5

avg_satisfaction <- hr %>%
  group_by(Department) %>%
  summarise(avg_satisfaction_level = mean(satisfaction_level, na.rm = TRUE))

plot_ly(avg_satisfaction, x = ~Department, y = ~avg_satisfaction_level, type = 'bar') %>%
  layout(title = 'Average Satisfaction Level by Department: Notable Differences in Satisfaction',
         xaxis = list(title = 'Department'),
         yaxis = list(title = 'Average Satisfaction Level'))
#most of the differences between department satisfaction are small, almost a hundreth of a differnce at most