1 Histogram: Distribution of Employee Satisfaction

Create a histogram of the satisfaction_level variable.

The title should reflect a key takeaway from the distribution.

plot_ly(hr, x = ~satisfaction_level,
        type = "histogram") %>%
  layout(title = "About 50% of employees are satisfied (satisfaction > 0.7",
         xaxis = list(title = "Satisfaction level"),
         yaxis = list(title = "Count of employees"))

2 Box Plot: Last Evaluation Scores Create a box plot of the last_evaluation variable.

The title should highlight an important insight about the evaluation scores

plot_ly(hr, y = ~last_evaluation, type = "box") %>%
  layout(title = "Last Evaluation Scores",
         yaxis = list(title = "x"))

3 Comparative Box Plot: Monthly Hours by Department

Create a comparative box plot of average_montly_hours grouped by department.

The title should emphasize a significant difference or pattern among departments.

plot_ly(hr, x = ~as.factor(Department), y = ~average_montly_hours, type = "box") %>%
  layout(title = "Same Monthly Hours",
         xaxis = list(title = "department"),
         yaxis = list(title = "average monthly hours"))

4Pie Chart of Frequencies: Attrition by Salary Level

#Create a pie chart showing the frequency of employee attrition (left) for each salary category. # The title should point out the relationship between salary and attrition.

left_by_salary <- hr %>% 
  filter(left == 1) %>% 
  count(salary)


plot_ly(left_by_salary, 
        labels = ~~paste(Salary_Level), values = ~n, type = 'pie') %>%
  layout(title = 'Relationship between Salary and Attrition')

5Bar Plot of Averages:

#Average Satisfaction by Department #Create a bar plot displaying the average satisfaction_level for each department. #The title should highlight a key observation about departmental satisfaction. # Calculate average satisfaction by department

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

Create the bar plot

plot_ly(avg_satisfaction, x = ~factor(Department), y = ~avg_satisfaction, type = 'bar') %>%
  layout(title = 'Average Satisfaction by Department',
         xaxis = list(title = 'Department'),
         yaxis = list(title = 'Average Satisfaction'))