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 = "Most Employees have a Satisfaction Level between 0.5 and 1",
         xaxis = list(title = "Employee Satisfaction Level"),
         yaxis = list(title = "Count"))

Analysis

● Most employees have a satisfaction level between 0.5 and 1

● The data is roughly bimodal

● The highest number of employees, 693, responded with a 0.1 satisfaction level

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 = "50% of Evaluation Scores fall between 0.56 and 0.87",
         yaxis = list(title = "Last Evaluation Scores"))

Analysis

● Median last evaluation score is around 0.72

● 50 % of evaluation scores fall between 0.56 and 0.87

● The distribution is slightly skewed towards higher last evaluation scores

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 = "There is about a Uniform Distribution Across the Departments",
         xaxis = list(title = "Department"),
         yaxis = list(title = "Average Monthly Hours"))

Analysis

● The management department has the highest median with 204 average monthly hours

● There is about a uniform distribution across all of the departments

● Sales, support, and marketing have the largest spread

4. Pie 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.

attrition_counts <- hr %>% 
  filter(left == "1") %>%
  group_by(salary, left) %>%
  count(left)
  
plot_ly(attrition_counts, labels = ~salary, values = ~n, type = 'pie') %>%
  layout(title = 'As the Salary Increases, Less Employees Leave')

Analysis

● Over 60% of employees left when receiving low salary

● Only a little over 2% of employees left when receiving a high salary

● As the salary increases, less employees leave

5. Bar 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.

avg_satisfaction <- hr %>% 
  group_by(Department) %>% 
  summarise(avg_satisfaction = mean(satisfaction_level))

plot_ly(avg_satisfaction, x = ~factor(Department), y = ~avg_satisfaction, type = 'bar') %>%
  layout(title = 'Accounting has the Lowest Average Satisfaction Level of 0.58',
         xaxis = list(title = 'Department'),
         yaxis = list(title = 'Average Satisfaction Level'))

Analysis

● The distribution of the data is about uniform

● Accounting has the lowest average satisfaction level of 0.58

● Management has the highest average satisfaction level of 0.62