R Markdown

#1. Histogram: Distribution of Employee Satisfaction # Create a histogram of the satisfaction_level variable. # The title should reflect a key takeaway from the distribution.

q1 <- plot_ly(hr, 
        x = ~satisfaction_level,
        type = "histogram") %>%
  layout(title = "about 50% of employees are satisfied (satisfaction > .7)",
         xaxis = list(title = "Satisfaction Level"),
         yaxis = list(title = "Count of Employees"))
q1  

About 50% of employees are highly satisfied (satisfaction > 0.7), though many report lower satisfaction.

#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.

q2 <- plot_ly(hr, 
        y = ~last_evaluation, 
        type = "box") %>% 
  layout(title = "Diverging Evaluation Scores: Evidence of High Performers and Underperformers", 
         yaxis = list(title = "Last Evaluation Scores"))

q2  

Evaluation scores vary widely, indicating a mix of high and low performers within the organization.

#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.

q3 <- plot_ly(hr, 
        x = ~as.factor(Department), 
        y = ~average_montly_hours, 
        type = "box") %>%
  layout(title = "Uneven Workload: Significant Variability in Monthly Hours Across Departments",
         xaxis = list(title = "Department"),
         yaxis = list(title = "Average Monthly Hours"))

q3  

Monthly hours differ by department, suggesting unequal workload distribution, which could impact employee satisfaction.

#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.

q4 <- hr %>% filter(left == 1) %>% count(salary)
plot_ly(q4, labels = ~salary, values = ~n, type = 'pie') %>%
  layout(title = 'Attrition Skewed Toward Lower Salaries: High Turnover Among Lower-Paid Employees')
q4
## # A tibble: 3 × 2
##   salary     n
##   <chr>  <int>
## 1 high      82
## 2 low     2172
## 3 medium  1317

Attrition is higher among lower-paid employees, indicating a possible link between low salary and turnover.

#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.

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

plot_ly(q5, x = ~factor(Department), y = ~satisfaction_level, type = 'bar') %>% 
  layout(title = 'Departmental Satisfaction Averages Over 50% but Below 65%',
         xaxis = list(title = 'Department'),
         yaxis = list(title = 'Average Satisfaction Level', range = c(0,1)))
q5
## # A tibble: 10 × 2
##    Department  satisfaction_level
##    <chr>                    <dbl>
##  1 IT                       0.618
##  2 RandD                    0.620
##  3 accounting               0.582
##  4 hr                       0.599
##  5 management               0.621
##  6 marketing                0.619
##  7 product_mng              0.620
##  8 sales                    0.614
##  9 support                  0.618
## 10 technical                0.608

Average satisfaction across departments is moderate (above 50% but below 65%), suggesting room for improvement in work culture.