library(readr)
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(hr$satisfaction_level, hr$last_evaluation)
##
## 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
ggplot(hr, aes(x = satisfaction_level, y = last_evaluation)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, color = "red") +
labs(title = "Satisfaction and Evaluation Scores Are Weakly Related",
x = "Satisfaction Level",
y = "Last Evaluation")
## `geom_smooth()` using formula = 'y ~ x'
Technical interpretation: The p-value is less than 0.05, so the correlation is statistically significant. This means there is evidence of a real relationship between satisfaction level and last evaluation score. The correlation is weak and positive.
Non-technical interpretation: Employee satisfaction and evaluation scores are only weakly related.
cor.test(hr$number_project, hr$average_montly_hours)
##
## 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
ggplot(hr, aes(x = time_spend_company, y = number_project)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, color = "red") +
labs(title = "Employees Who Stay Longer Work on More Projects",
x = "Time at Company",
y = "Number of Projects")
## `geom_smooth()` using formula = 'y ~ x'
Technical interpretation: The p-value is less than 0.05, so the correlation is statistically significant. This indicates a moderate positive relationship between number of projects and average monthly hours.
Non-technical interpretation: Employees who work on more projects tend to work more hours.
cor.test(hr$average_montly_hours, hr$satisfaction_level)
##
## 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
ggplot(hr, aes(x = average_montly_hours, y = satisfaction_level)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, color = "red") +
labs(title = "Working More Hours Slightly Lowers Satisfaction",
x = "Average Monthly Hours",
y = "Satisfaction Level")
## `geom_smooth()` using formula = 'y ~ x'
Technical interpretation: The p-value is less than 0.05, so the correlation is statistically significant. This indicates a moderate positive relationship between time spent at the company and number of projects.
Non-technical interpretation: Employees who stay longer at the company tend to work on more projects.
cor.test(hr$number_project, hr$average_montly_hours)
##
## 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
ggplot(hr, aes(x = number_project, y = average_montly_hours)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, color = "red") +
labs(title = "More Projects Lead to More Work Hours",
x = "Number of Projects",
y = "Average Monthly Hours")
## `geom_smooth()` using formula = 'y ~ x'
Technical interpretation: The p-value is less than 0.05, so the correlation is statistically significant. This indicates a very weak negative relationship between average monthly hours and satisfaction level.
Non-technical interpretation: Working more hours is slightly associated with lower employee satisfaction.