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.
cor_test <- cor.test(hr$satisfaction_level, hr$average_montly_hours)
cor_test
##
## Pearson's product-moment correlation
##
## data: hr$satisfaction_level and hr$average_montly_hours
## 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
The Correlation Coefficient is -0.020, nearly zero. There is practically no relationship between satisfaction_level and average_montly_hours because the p-value is nearly zero so there is a small negative correlation.
There is no impact from the employees working more hours and their satisfaction levels.
ggplot(hr, aes(x = average_montly_hours, y = satisfaction_level)) +
geom_point(alpha = 0.5) +
geom_smooth(method = "lm", color = "blue") +
labs(
title = "No Association Between Satisfaction Level and Average Monthly Hours Worked",
x= "Average Monthly Hours Worked",
y = "Satisfaction Level"
)
## `geom_smooth()` using formula = 'y ~ x'
cor_test_time_spent <- cor.test(hr$average_montly_hours, hr$time_spend_company)
cor_test_time_spent
##
## Pearson's product-moment correlation
##
## data: hr$average_montly_hours and hr$time_spend_company
## 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
The Correlation Coefficient is 0.1277, nearly zero. There is practically no relationship between time spent at the company and average_montly_hours because the p-value is nearly zero so ther is a small positive correlation.
The average monthly hours worked is not influenced by the time spent at the company.
ggplot(hr, aes(x = average_montly_hours, y = time_spend_company)) +
geom_point(alpha = 0.5) + # Scatter plot points
geom_smooth(method = "lm", color = "blue") + # Linear regression line
labs(
title = "There is no clear relationship between time spent working and time spent at the company",
x = "Average Monthly Hours Worked",
y = "Time Spent at the Company (Years)"
)
## `geom_smooth()` using formula = 'y ~ x'
cor_test_time_spent <- cor.test(hr$satisfaction_level, hr$last_evaluation)
cor_test_time_spent
##
## 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
The correlation coefficient is .1050, there is a small positive correlation between satisfaction level and last evaluation.
There is a small association between satisfaction level and last evaluation, last evaluations hardly impact satisfaction levels.
ggplot(hr, aes(x = satisfaction_level, y = last_evaluation)) +
geom_jitter(width = 0.2, alpha = 0.5) +
geom_smooth(method = "lm", color = "blue") +
labs(title = "Weak positive correlation between Satisfaction and Last Evaluation",
x = "Satisfaction Level",
y = "Last Evaluation")
## `geom_smooth()` using formula = 'y ~ x'
cor_test_time_spent <- cor.test(hr$average_montly_hours, hr$last_evaluation)
cor_test_time_spent
##
## Pearson's product-moment correlation
##
## data: hr$average_montly_hours and hr$last_evaluation
## t = 44.237, df = 14997, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.3255078 0.3538218
## sample estimates:
## cor
## 0.3397418
The correlation coefficient is .3397, there is a moderate postitive correlation between average monthly hours and last evaluation.
Average monthly hours have a moderate impact on the employees last evaluation.
ggplot(hr, aes(x = last_evaluation, y = average_montly_hours)) +
geom_jitter(width = 0.2, alpha = 0.5) +
geom_smooth(method = "lm", color = "blue") +
labs(title = "Relationship between Last Evaluation and Average Monthly Hours",
x = "Last Evaluation",
y = "Average Monthly Hours")
## `geom_smooth()` using formula = 'y ~ x'