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
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(readr)

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.

First Correlation

task_1 <- cor.test(hr$average_montly_hours, hr$satisfaction_level)

print(task_1)
## 
##  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 somewhat small indicating very little correlation between the variables

correlation estimate interpretation: The correlation is negative and small

non-technical interpretation: The more monthly hours worked the less satisfied the employees

library(ggplot2)

ggplot(hr, aes(x = satisfaction_level, y = average_montly_hours)) +
  geom_point() +
  geom_smooth(method = "lm", se = FALSE, color = "red") +
  labs(title = "More Monthly Hours, less Satisfaction",
       x = "Satisfaction Level",
       y = "Average Monthly Hours")
## `geom_smooth()` using formula = 'y ~ x'

Second Correlation

task_2 <- cor.test(hr$number_project, hr$last_evaluation)

print(task_2)
## 
##  Pearson's product-moment correlation
## 
## data:  hr$number_project and hr$last_evaluation
## 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 very small indicating strong correlation

correlation estimate interpretation: The correlation is positive and large

non-technical interpretation: The more projects being completed the more likely to have a recent evaluation

ggplot(hr, aes(x = number_project, y = last_evaluation)) +
  geom_point() +
  geom_smooth(method = "lm", se = FALSE, color = "red") +
  labs(title = "More Projects, more Evaluation",
       x = "Number of Projects",
       y = "Last Evaluation")
## `geom_smooth()` using formula = 'y ~ x'

Third Correlation

task_3 <- cor.test(hr$time_spend_company, hr$satisfaction_level)

print(task_3)
## 
##  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: The p-value is very small pointing towards correlation

correlation estimate interpretation: The correlation is negative and large

non-technical interpretation: The longer someone spends with the company the less satisfied they are

ggplot(hr, aes(x = time_spend_company, y = satisfaction_level)) +
  geom_point() +
  geom_smooth(method = "lm", se = FALSE, color = "red") +
  labs(title = "More Time Spent in Company, less Satisfaction",
       x = "Time Spent in Company",
       y = "Satisfaction")
## `geom_smooth()` using formula = 'y ~ x'

Fourth Correlation

task_4 <- cor.test(hr$left, hr$promotion_last_5years)

print(task_4)
## 
##  Pearson's product-moment correlation
## 
## data:  hr$left and hr$promotion_last_5years
## t = -7.5812, df = 14997, p-value = 3.624e-14
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.07771507 -0.04582962
## sample estimates:
##         cor 
## -0.06178811

p-value interpretation: The p-value is small and indicates strong interpretation

correlation estimate interpretation: Correlation is negative and small

non-technical interpretation: No promotion within five years more likely to leave

ggplot(hr, aes(x = promotion_last_5years, y = left)) +
  geom_point() +
  geom_smooth(method = "lm", se = FALSE, color = "red") +
  labs(title = "No Promotion, less Employees",
       x = "Promotion Past Five Years",
       y = "Employees Who Left the Company")
## `geom_smooth()` using formula = 'y ~ x'