Instructions

Part A - Perform the correlation (.5 point) Choose any two appropriate variables from the data and perform the correlation, displaying the results.

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

Part C - Interpret the results in non-technical terms (1 point) For each correlation, what do the results mean in non-techical terms.

Part D - Create a plot that helps visualize the correlation (.5 point) For each correlation, create a graph to help visualize the realtionship between the two variables. The title must be the non-technical interpretation.

Run the plotly and readr packages

library(readr)
library(plotly)
## Loading required package: ggplot2
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout

Insert the hr data set

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. Number of Projects and Average Monthly Hours

a.

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

b.
There is a significant moderate positive correlation.

c.
The more projects someone does, the more hours they work on average.

d.

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

2. Last Evaluation and Average Monthly Hours

a.

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

b.
There is a significant moderate positive correlation.

c.
The more hours someone works, the higher they score on their evaluation.

d.

ggplot(hr, aes(x = last_evaluation, y = average_montly_hours)) +
  geom_point() +
  geom_smooth(method = "lm", se = FALSE, color = "red") +
  labs(title = "Scatter Plot: Score on Last Evaluation vs. Average Monthly Hours",
       x = "Score on Last Evalutation",
       y = "Average Monthly Hours")
## `geom_smooth()` using formula = 'y ~ x'

3. Time Spend Company and Satisfaction Level

a.

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

b.
There is a significant weak negative correlation.

c.
As employees spend more time at the company, their satisfaction level slightly decreases.

d.

ggplot(hr, aes(x = time_spend_company, y = satisfaction_level)) +
  geom_point() +
  geom_smooth(method = "lm", se = FALSE, color = "red") +
  labs(title = "Scatter Plot: Time Spent at Company vs Satisfaction Level",
       x = "Time Spent at Company",
       y = "Satisfaction Level") 
## `geom_smooth()` using formula = 'y ~ x'

4. Number of Projects and Satisfaction Level

a.

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

b.
There is a significant weak negative correlation.

c.
As employees complete more projects, their satisfaction level slightly decreases.

d.

ggplot(hr, aes(x = number_project, y = satisfaction_level)) +
  geom_point() +
  geom_smooth(method = "lm", se = FALSE, color = "red") +
  labs(title = "Scatter Plot: Number of Employee Projects vs Satisfaction Level",
       x = "Number of Employee Projects",
       y = "Satisfaction Level") 
## `geom_smooth()` using formula = 'y ~ x'