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.
Question 1
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
P-value interpretation: The p-value is greater than our significance
level of .01, so the coorelation is not statistically significant
Correlation estimate interpretation: There is no coorelation
Non-technical interpretation: No relationship between average
monthly hours and satisfaction level
ggplot(hr, aes(x = average_montly_hours, y = satisfaction_level)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, color = "red") +
labs(title = "No correlation between Average Monthly Hours and Satisfaction Level",
x = "Average Monthly Hours",
y = "Satisfaction Level")
## `geom_smooth()` using formula = 'y ~ x'

Question 2
cor.test(hr$time_spend_company, hr$satisfaction_level)
##
## Pearson's product-moment correlation
##
## data: hr$time_spend_company and hr$satisfaction_level
## t = -12.416, df = 14997, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.11668153 -0.08499948
## sample estimates:
## cor
## -0.1008661
P-value interpretation: P value is extremely small, so the
coorelation is statistically significant
Correlation estimate interpretation: The coorelation is negative and
relatively small
Non-technical interpretation: The more time spent at the company,
the less satisfied an employee is
ggplot(hr, aes(x = time_spend_company, y = satisfaction_level)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, color = "blue") +
labs(title = "More time at the company, less satisfaction",
x = "Time Spent at Company",
y = "Satisfaction Level")
## `geom_smooth()` using formula = 'y ~ x'

Question 3
cor.test(hr$last_evaluation, hr$number_project)
##
## Pearson's product-moment correlation
##
## data: hr$last_evaluation and hr$number_project
## 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
P-value interpretation: P value is extremely small, so the
coorelation is statistically significant
Correlation estimate interpretation: The coorealtion is positive and
relatively large
Non-technical interpretation: As the number of projects increases,
so does their last evaluation score
ggplot(hr, aes(x = last_evaluation, y = number_project)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, color = "green") +
labs(title = "Greater number of projects, higher last evaluation",
x = "Last Evaluation",
y = "Number Project ")
## `geom_smooth()` using formula = 'y ~ x'

Question 4
cor.test(hr$number_project, hr$satisfaction_level)
##
## Pearson's product-moment correlation
##
## data: hr$number_project and hr$satisfaction_level
## 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
P-value interpretation: P value is extremely small, so the
coorelation is statistically significant
Correlation estimate interpretation: The coorealtion is negative but
relatively small
Non-technical interpretation: As the number of projects increases,
satisfaction level decreases
ggplot(hr, aes(x = number_project, y = satisfaction_level)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, color = "purple") +
labs(title = "More projects, less satisfaction level",
x = "Number of Projects",
y = "Satisfaction Levels")
## `geom_smooth()` using formula = 'y ~ x'
