Load necessary libraries and datasets

library(readr)
library(ggplot2)
hr <- read_csv('https://raw.githubusercontent.com/aiplanethub/Datasets/refs/heads/master/HR_comma_sep.csv')

Question 1

cor1 <- cor.test(hr$satisfaction_level, hr$last_evaluation)
print(cor1)
## 
##  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 slightly positive and very small, so the correlation between satisfaction level and last evaluation is statistically significant.

# Non-technical interpretation: Employees with higher satisfaction also have slightly higher evaluations

Plot 1: Satisfaction Level vs Last Evaluation

# Plot 1: Satisfaction Level vs Last Evaluation
ggplot(hr, aes(x = satisfaction_level, y = last_evaluation)) +
  geom_point() +
  geom_smooth(method = "lm", color = "red",se = FALSE) +
  labs(title = "Slight Positive Relationship Between Satisfaction and Evaluation",
       x = "Satisfaction Level", y = "Last Evaluation")
## `geom_smooth()` using formula = 'y ~ x'

Question 2

cor2 <- cor.test(hr$satisfaction_level, hr$average_montly_hours)
print(cor2)
## 
##  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
# Technical interpretation: The p-value is slightly negative and very small, so the correlation between satisfaction level and average monthly hours worked is significant 

# Non-technical interpretation: Employees with more hours worked are slightly less satisfied

Plot 2: Satisfaction Level vs Average Monthly Hours

# Plot 2: Satisfaction Level vs Average Monthly Hours
ggplot(hr, aes(x = satisfaction_level, y = average_montly_hours)) +
  geom_point() +
  geom_smooth(method = "lm", color = "red", se = FALSE) +
  labs(title = "Minimal Negative Relationship Between Satisfaction and Monthly Hours",
       x = "Satisfaction Level", y = "Average Monthly Hours")
## `geom_smooth()` using formula = 'y ~ x'

# Question 3

cor3 <- cor.test(hr$last_evaluation, hr$average_montly_hours)
print(cor3)
## 
##  Pearson's product-moment correlation
## 
## data:  hr$last_evaluation and hr$average_montly_hours
## 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: A large p-value and positive, significant correlation between last evaluation and average monthly hours worked.

# Non-technical interpretation: Employees with more monthly hours have higher evaluations

Plot 3: Last Evaluation vs Average Monthly Hours

# Plot 3: Last Evaluation vs Average Monthly Hours
ggplot(hr, aes(x = last_evaluation, y = average_montly_hours)) +
  geom_point(alpha = 0.5) +
  geom_smooth(method = "lm", color = "red", se = FALSE) +
  labs(title = "Higher Evaluations Linked to More Monthly Hours",
       x = "Last Evaluation", y = "Average Monthly Hours")
## `geom_smooth()` using formula = 'y ~ x'

# Question 4

cor4 <- cor.test(hr$number_project, hr$average_montly_hours)
print(cor4)
## 
##  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
# Technical interpretation: A positive correlation between number of projects and average monthly hours is statistically significant

# Non-technical interpretation: Employees who work more hours on average have more projects done/assigned.

Plot 4: Number of Projects vs Average Monthly Hours

# Plot 4: Number of Projects vs Average Monthly Hours
ggplot(hr, aes(x = number_project, y = average_montly_hours)) +
  geom_point(alpha = 0.5) +
  geom_smooth(method = "lm", color = "red", se = FALSE) +
  labs(title = "More Projects, More Monthly Hours",
       x = "Number of Projects", y = "Average Monthly Hours")
## `geom_smooth()` using formula = 'y ~ x'