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"))
plot_ly(hr, y = ~last_evaluation, type = "box") %>%
layout(title = "Last Evaluation Scores",
yaxis = list(title = "x"))
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"))
#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')
#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))
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'))