# Load the HR dataset
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.
1.
# Perform the correlation
correlation_1 <- cor.test(hr$satisfaction_level, hr$last_evaluation)
# Display the correlation result
correlation_1
##
## 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
4.7043116^{-38}, which indicates whether the correlation is
statistically significant.
- Non-Technical Interpretation: The relationship
between satisfaction level and last evaluation score suggests that
higher satisfaction may be associated with higher evaluation
scores.
# Visualization
ggplot(hr, aes(x = satisfaction_level, y = last_evaluation)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, color = "red") +
labs(title = "Higher Satisfaction, Higher Evaluation Score",
x = "Satisfaction Level",
y = "Last Evaluation Score")
## `geom_smooth()` using formula = 'y ~ x'

2.
# Perform the correlation
correlation_2 <- cor.test(hr$average_montly_hours, hr$last_evaluation)
# Display the correlation result
correlation_2
##
## 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
- Technical Interpretation: The p-value is 0,
suggesting the significance of the relationship.
- Non-Technical Interpretation: The results show that
as average monthly hours increase, evaluation scores also tend to
rise.
# Visualization
ggplot(hr, aes(x = average_montly_hours, y = last_evaluation)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, color = "blue") +
labs(title = "More Hours Worked, Higher Evaluation Score",
x = "Average Monthly Hours",
y = "Last Evaluation Score")
## `geom_smooth()` using formula = 'y ~ x'

3.
# Perform the correlation
correlation_3 <- cor.test(hr$satisfaction_level, hr$number_project)
# Display the correlation result
correlation_3
##
## 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
- Technical Interpretation: The p-value is
2.5268359^{-69}, indicating the statistical significance of this
correlation.
- Non-Technical Interpretation: Higher satisfaction
levels may be associated with fewer projects, indicating possible stress
with higher workloads.
# Visualization
ggplot(hr, aes(x = number_project, y = satisfaction_level)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, color = "green") +
labs(title = "More Projects, Lower Satisfaction",
x = "Number of Projects",
y = "Satisfaction Level")
## `geom_smooth()` using formula = 'y ~ x'

4.
# Perform the correlation
correlation_4 <- cor.test(hr$time_spend_company, hr$average_montly_hours)
# Display the correlation result
correlation_4
##
## 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
1.306156^{-55}, showing the significance level of this
relationship.
- Non-Technical Interpretation: Employees who have
spent more time at the company tend to work more hours on average each
month.
# Visualization
ggplot(hr, aes(x = time_spend_company, y = average_montly_hours)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, color = "purple") +
labs(title = "Longer Tenure, More Monthly Hours",
x = "Time Spent at Company (Years)",
y = "Average Monthly Hours")
## `geom_smooth()` using formula = 'y ~ x'
