library(readr)
library(ggplot2)
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.
Correlation 1: Satisfaction Level vs. Last Evaluation
cor1 <- cor.test(hr$satisfaction_level, hr$last_evaluation)
cor1
##
## Pearson's product-moment correlation
##
## data: hr$satisfaction_level and hr$last_evaluation
## t = 12.933, df = 14997, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.08916727 0.12082195
## sample estimates:
## cor
## 0.1050212
Technical interpretation:
- The p-value is extremely small, therefore the correlation between
satisfaction level and last evaluation is significant.
- The correlation is slightly positive.
Non-technical interpretation:
- Higher satisfaction levels indicates slightly higher last evaluation
scores.
ggplot(hr, aes(x = satisfaction_level, y = last_evaluation)) +
geom_point(alpha = 0.5) +
geom_smooth(method = "lm", se = FALSE, color = "red") +
labs(title = "Higher Satisfaction Slightly Increases Evaluation Scores",
x = "Satisfaction Level",
y = "Last Evaluation Score")
## `geom_smooth()` using formula = 'y ~ x'

Correlation 2: Number of Projects vs. Average Monthly Hours
cor2 <- cor.test(hr$number_project, hr$average_montly_hours)
cor2
##
## Pearson's product-moment correlation
##
## data: hr$number_project and hr$average_montly_hours
## t = 56.219, df = 14997, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.4039037 0.4303411
## sample estimates:
## cor
## 0.4172106
Technical interpretation:
- The p-value is extremely small, therefore the correlation is
significant.
- The correlation is weak and positive.
Non-technical interpretation:
- Employees with more projects work more hours each month.
ggplot(hr, aes(x = number_project, y = average_montly_hours)) +
geom_point(alpha = 0.5) +
geom_smooth(method = "lm", se = FALSE, color = "blue") +
labs(title = "More Projects Lead to More Monthly Hours",
x = "Number of Projects",
y = "Average Monthly Hours")
## `geom_smooth()` using formula = 'y ~ x'

Correlation 3: Time Spent at Company vs. Average Monthly Hours
cor3 <- cor.test(hr$time_spend_company, hr$average_montly_hours)
cor3
##
## Pearson's product-moment correlation
##
## data: hr$time_spend_company and hr$average_montly_hours
## t = 15.774, df = 14997, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.1119801 0.1434654
## sample estimates:
## cor
## 0.1277549
Technical interpretation:
- The p-value is small, therefore the correlation is significant.
- The correlation is moderately positive.
Non-technical interpretation:
- Employees with who have been at the company longer work slightly
more hours per month.
ggplot(hr, aes(x = time_spend_company, y = average_montly_hours)) +
geom_point(alpha = 0.5) +
geom_smooth(method = "lm", se = FALSE, color = "green") +
labs(title = "Longer Tenure Slightly Increases Monthly Hours",
x = "Time at Company (Years)",
y = "Average Monthly Hours")
## `geom_smooth()` using formula = 'y ~ x'

Correlation 4: Satisfaction Level vs. Time Spent at Company
cor4 <- cor.test(hr$satisfaction_level, hr$time_spend_company)
cor4
##
## Pearson's product-moment correlation
##
## data: hr$satisfaction_level and hr$time_spend_company
## t = -12.416, df = 14997, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.11668153 -0.08499948
## sample estimates:
## cor
## -0.1008661
Technical interpretation:
- The p-value is small, therefore the correlation is significant.
- The correlation is negative and weak.
Non-technical interpretation:
- Employees who have been at company longer have slightly lower
satisfaction levels.
ggplot(hr, aes(x = time_spend_company, y = satisfaction_level)) +
geom_point(alpha = 0.5) +
geom_smooth(method = "lm", se = FALSE, color = "purple") +
labs(title = "Longer Tenure May Decrease Satisfaction",
x = "Time at Company (Years)",
y = "Satisfaction Level")
## `geom_smooth()` using formula = 'y ~ x'
