library(readr)
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
library (ggplot2)
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)
print(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 very small, therfore the correlation
between satisfaction level and last evaluation is significant.
Correlation estimate interpretation
The correlation is moderate and positive.
Non-technical interpretation
Happier employees tend to receive better evaluations.
ggplot(hr, aes(x = last_evaluation, y = satisfaction_level)) +
geom_point(alpha = 0.5) +
geom_smooth(method = "lm", se = FALSE, color = "red") +
labs(title = "Higher Evaluations, More Employee Satisfaction",
x = "Last Evaluation",
y = "Satisfaction Level")
## `geom_smooth()` using formula = 'y ~ x'

Correlation 2: Average Monthly Hours vs. Satsifaction Level
cor2 <- cor.test(hr$average_montly_hours, hr$satisfaction_level)
print(cor2)
##
## Pearson's product-moment correlation
##
## data: hr$average_montly_hours and hr$satisfaction_level
## t = -2.4556, df = 14997, p-value = 0.01408
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.036040356 -0.004045605
## sample estimates:
## cor
## -0.02004811
Technical interpretation
The p-value is very small, therefore the correlation between
average monthly hours and satisfaction level is significant.
Correlation estimate interpretation
The correlation is moderate and negative.
Non-technical interpretation
Employees who work more hours on average tend to feel less
satisfied with their jobs.
ggplot(hr, aes(x = average_montly_hours, y = satisfaction_level)) +
geom_point(alpha = 0.5) +
geom_smooth(method = "lm", se = FALSE, color = "blue") +
labs(title = "More Hours Worked, Less Satisfaction",
x = "Average Monthy Hours",
y = "Satisfaction Level")
## `geom_smooth()` using formula = 'y ~ x'

Correlation 3: Number of Projects vs Last Evaluation
cor3 <- cor.test(hr$number_project, hr$last_evaluation)
print(cor3)
##
## Pearson's product-moment correlation
##
## data: hr$number_project and hr$last_evaluation
## t = 45.656, df = 14997, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.3352028 0.3633053
## sample estimates:
## cor
## 0.3493326
Technical interpretation
The p-value is very small, therefore the correlation between
number of projects and last evaluation is significant.
Correlation estimate interpretation
The correlation is strong and positive.
Non-technical interpretation
Employees who handle more projects generally receive better
evaluations.
ggplot(hr, aes(x = number_project, y =last_evaluation)) +
geom_point(alpha = 0.5) +
geom_smooth(method = "lm", se = FALSE, color = "green") +
labs(title = "More Projects, Higher Evaluation",
x = "Number of Projects",
y = "Last Evaluation")
## `geom_smooth()` using formula = 'y ~ x'

Correlation 4: Time Spent at Company vs. Last Evaluation
cor4 <- cor.test(hr$time_spend_company, hr$last_evaluation)
print(cor4)
##
## Pearson's product-moment correlation
##
## data: hr$time_spend_company and hr$last_evaluation
## t = 16.256, df = 14997, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.1158309 0.1472844
## sample estimates:
## cor
## 0.1315907
Technical interpretation
The p-value is very small, therefore the correlation between
time spent at the company and last evaluations is significant.
Correlation estimate interpretation
The correlation is moderate and positive.
Non-technical interpretation
Employees who have spent more time at the company tend to
receive
higher evaluations.
ggplot(hr, aes(x = time_spend_company, y = last_evaluation)) +
geom_point(alpha = 0.5) +
geom_smooth(method = "lm", se = FALSE, color = "purple") +
labs(title = "Longer Time at Company, Better Evaluations",
x = "Time Spent at Company (Years)",
y = "Last Evaluation")
## `geom_smooth()` using formula = 'y ~ x'
