library(readr)
library(plotly)
## Loading required package: ggplot2
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
hr <- read_csv('https://raw.githubusercontent.com/aiplanethub/Datasets/refs/heads/master/HR_comma_sep.csv')
## Rows: 14999 Columns: 10
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (2): Department, salary
## dbl (8): satisfaction_level, last_evaluation, number_project, average_montly...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

1. Histogram

plot_ly(hr, x = ~satisfaction_level, type = "histogram") %>%
  layout(title = "Most Employees Are Satisfied (satisfaction > .5)",
         xaxis = list(title = "Satisfaction Level"),
         yaxis = list(title = "Number of Employees"))

Analysis

- Most employees are satisfied (satisfaction > .5)

- About 6% of employees are extremely dissatisfied (satisfaction <= .11)

2. Box Plot

plot_ly(hr, y = ~last_evaluation, type = "box") %>%
  layout(title = "Most Employees Scored Above Average (average > .5)",
         xaxis = list(title = "Evaluation Score"),
         yaxis = list(title = "Frequency"))

Analysis

- 50% of employees score between .56 and .87

- The lowest employee score was .36

3. Comparative Box Plot

plot_ly(hr, x = ~average_montly_hours, y = ~Department, type = "box") %>%
  layout(title = "All Departments Have Very Similar Hours Totals",
         xaxis = list(title = "Average Monthly Hours"),
         yaxis = list(title = "Department"))

Analysis

- Department median scores are pretty similar, the difference between the highest and lowest is only 7

- Support, sales, and marketing all have the greatest range of 114

4. Pie Chart of Frequencies

left <- hr %>% filter(left == 1)
plot_ly(left, labels = ~salary,  type = 'pie') %>%
  layout(title = 'Most peopl who leave the company have low salaries')

Analysis

- Only about 2% of people who leave the company have high salaries

- Approximately 3 out of every 5 people who leave the company have low salaries

5. Bar Plot of Averages

plot_ly(hr, x = ~mean(satisfaction_level), y = ~Department, type = 'bar') %>%
  layout(title = 'Sales has the greatest satisfaction level',
         xaxis = list(title = 'Average Satirsfaction Level'),
         yaxis = list(title = 'Department'))

Analysis

- Sales has about a 5 times greater satisfaction level than marketing

- Most of the data has a relatively low satisfaction level