Load libraries

library(readr)
library(ggplot2)

Load data

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. Choose any two appropriate variables from the data and perform the correlation, displaying the results.

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

2. Interpret the results in technical terms.For each correlation, explain what the test’s p-value means (significance).

The p-value is less than 0.05, which means the correlation is statistically significant. Because the p-value is extremely small,
we reject the null hypothesis and conclude that there is evidence of a relationship between satisfaction level and last evaluation.
————————————————————————————————————————————-
The correlation coefficient is 0.28, which indicates a positive and small-to-moderate relationship. This means that as satisfaction
increases, last evaluation scores tend to increase as well, but not perfectly.

3. Interpret the results in non-technical terms.For each correlation, what do the results mean in non-techical terms.

Employees who are more satisfied tend to receive better performance evaluations.In other words, happier employees usually get higher performance ratings.

4. Create a plot that helps visualize the correlation. For each correlation, create a graph to

help visualize the realtionship between the two variables. The title must be the non-technical interpretation.

ggplot(hr, aes(x = last_evaluation, y = satisfaction_level)) +
  geom_point(alpha = 0.2) +
  geom_smooth(method = "lm", se = FALSE, color = "blue") +
  labs(
    title = "Last Evaluation Score VS Satisfaction Level",
    x = "Last Evaluation Score",
    y = "Satisfaction Level"
  )
## `geom_smooth()` using formula = 'y ~ x'

Employees who are more satisfied tend to receive better performance evaluations.

1. Perform the correlation. Choose any two appropriate variables from the data and perform the correlation, displaying the results.

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

2. Interpret the results in technical terms.For each correlation, explain what the test’s p-value means (significance).

The p-value is less than 0.05, meaning the correlation is statistically significant. Because the p-value is extremely small,
we reject the null hypothesis and conclude that there is evidence of a relationship between number of projects and monthly hours worked.
——————————————————————————————————————————
The correlation coefficient is 0.42, indicating a moderate positive relationship. This means that employees who have more projects
tend to work more hours per month.

3. Interpret the results in non-technical terms.For each correlation, what do the results mean in non-techical terms.

Employees with more assigned projects work more hours each month.

4. Create a plot that helps visualize the correlation. For each correlation, create a graph to

help visualize the realtionship between the two variables. The title must be the non-technical interpretation.

ggplot(hr, aes(x = number_project, y = average_montly_hours)) +
geom_point(alpha = 0.2) +
geom_smooth(method = "lm", se = FALSE, color = "blue") +
labs(
title = "Employees with more projects work more monthly hours",
x = "Number of Projects",
y = "Average Monthly Hours"
)
## `geom_smooth()` using formula = 'y ~ x'

Employees with more assigned projects work more hours each month.

1. Perform the correlation. Choose any two appropriate variables from the data and perform the correlation, displaying the results.

cor.test(hr$satisfaction_level, hr$time_spend_company)
## 
##  Pearson's product-moment correlation
## 
## data:  hr$satisfaction_level and hr$time_spend_company
## 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

2. Interpret the results in technical terms.For each correlation, explain what the test’s p-value means (significance).

The p-value is less than 0.05, so the correlation is statistically significant. Because the p-value is extremely small,
——————————————————————————————————————————
The correlation coefficient is -0.10, which shows a small negative relationship. This means that as employees stay at the
company longer, their satisfaction tends to decrease slightly.

3. Interpret the results in non-technical terms.For each correlation, what do the results mean in non-techical terms.

Employees who stay at the company longer tend to be slightly less satisfied.

4. Create a plot that helps visualize the correlation. For each correlation, create a graph to

help visualize the realtionship between the two variables. The title must be the non-technical interpretation.

ggplot(hr, aes(x = time_spend_company, y = satisfaction_level)) +
geom_point(alpha = 0.2) +
geom_smooth(method = "lm", se = FALSE, color = "blue") +
labs(
title = "Employees who stay longer tend to be slightly less satisfied",
x = "Years at Company",
y = "Satisfaction Level"
)
## `geom_smooth()` using formula = 'y ~ x'

Employees who stay at the company longer tend to be slightly less satisfied.

1. Perform the correlation. Choose any two appropriate variables from the data and perform the correlation, displaying the results.

cor.test(hr$last_evaluation, hr$average_montly_hours)
## 
##  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

2. Interpret the results in technical terms.For each correlation, explain what the test’s p-value means (significance).

The p-value is less than 0.05, indicating the correlation is statistically significant. The extremely small p-value means
——————————————————————————————————————————
The correlation coefficient is 0.34, which shows a moderate positive relationship. This means employees with higher evaluation
scores tend to work more hours per month.

3. Interpret the results in non-technical terms.For each correlation, what do the results mean in non-techical terms.

Employees with higher performance evaluation scores tend to work more hours.

4. Create a plot that helps visualize the correlation. For each correlation, create a graph to

help visualize the realtionship between the two variables. The title must be the non-technical interpretation.

ggplot(hr, aes(x = average_montly_hours, y = last_evaluation)) +
geom_point(alpha = 0.2) +
geom_smooth(method = "lm", se = FALSE, color = "blue") +
labs(
title = "Employees with higher evaluation scores tend to work more hours",
x = "Average Monthly Hours",
y = "Last Evaluation Score"
)
## `geom_smooth()` using formula = 'y ~ x'

Employees who are more satisfied tend to receive better performance evaluations.