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.
head(hr)
## # A tibble: 6 × 10
## satisfaction_level last_evaluation number_project average_montly_hours
## <dbl> <dbl> <dbl> <dbl>
## 1 0.38 0.53 2 157
## 2 0.8 0.86 5 262
## 3 0.11 0.88 7 272
## 4 0.72 0.87 5 223
## 5 0.37 0.52 2 159
## 6 0.41 0.5 2 153
## # ℹ 6 more variables: time_spend_company <dbl>, Work_accident <dbl>,
## # left <dbl>, promotion_last_5years <dbl>, Department <chr>, salary <chr>
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
The p-value tells us if the relationship between satisfaction and
last evaluation is statistically significant.
A small p-value (< 0.05) means the correlation is
significant.
Employees who are more satisfied tend to also have higher evaluation scores.
ggplot(hr, aes(x = last_evaluation, y = satisfaction_level)) +
geom_point(alpha = 0.3) +
geom_smooth(method = "lm", se = FALSE) +
labs(title = "Higher Satisfaction is Linked to Higher Evaluation Scores",
x = "Last Evaluation Score",
y = "Satisfaction Level")
## `geom_smooth()` using formula = 'y ~ x'
cor.test(hr$average_montly_hours, hr$last_evaluation)
##
## 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 p-value indicates whether average monthly hours and evaluation
score are significantly related.
If p < 0.05, the correlation is significant.
Employees who work more hours tend to have higher evaluation scores.
ggplot(hr, aes(x = average_montly_hours, y = last_evaluation)) +
geom_point(alpha = 0.3) +
geom_smooth(method = "lm", se = FALSE) +
labs(title = "Employees Working More Hours Tend to Have Higher Evaluations",
x = "Average Monthly Hours",
y = "Last Evaluation Score")
## `geom_smooth()` using formula = 'y ~ x'
cor.test(hr$time_spend_company, hr$number_project)
##
## Pearson's product-moment correlation
##
## data: hr$time_spend_company and hr$number_project
## t = 24.579, df = 14997, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.1813532 0.2121217
## sample estimates:
## cor
## 0.1967859
The p-value tells us whether years at the company and number of
projects have a significant correlation.
If p < 0.05 → statistically significant.
Employees who spend more years at the company tend to work on more projects.
ggplot(hr, aes(x = time_spend_company, y = number_project)) +
geom_point(alpha = 0.3) +
geom_smooth(method = "lm", se = FALSE) +
labs(title = "More Years at the Company Means More Projects Handled",
x = "Years at Company",
y = "Number of Projects")
## `geom_smooth()` using formula = 'y ~ x'
cor.test(hr$satisfaction_level, hr$number_project)
##
## Pearson's product-moment correlation
##
## data: hr$satisfaction_level and hr$number_project
## t = -17.69, df = 14997, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.1586105 -0.1272570
## sample estimates:
## cor
## -0.1429696
The p-value tells us if satisfaction and number of projects have a statistically significant relationship.
Employees with more projects tend to be less satisfied.
ggplot(hr, aes(x = number_project, y = satisfaction_level)) +
geom_point(alpha = 0.3) +
geom_smooth(method = "lm", se = FALSE) +
labs(title = "Employees With More Projects Tend to Be Less Satisfied",
x = "Number of Projects",
y = "Satisfaction Level")
## `geom_smooth()` using formula = 'y ~ x'