Correlation One
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
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.
View(hr)
cor.test(hr$satisfaction_level , hr$average_montly_hours)
##
## 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
ggplot(hr, aes(x = average_montly_hours, y = satisfaction_level)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, color = "purple") +
labs(title = "Minimal to no relationship between average monthly hours and satisfaction level",
x = "Average Monthly Hours",
y = "Satisfaction Level")
## `geom_smooth()` using formula = 'y ~ x'

P-value interpretation: The p-value isn’t to small but small enough
to likely mean that there’s some statistical significance.
Correlation estimate interpretation: The correlation weak and
negative.
Non-technical interpretation: There is minimal to no relationship
between average monthly hours and satisfaction level.
Correlation Two
cor.test(hr$average_montly_hours , hr$number_project)
##
## Pearson's product-moment correlation
##
## data: hr$average_montly_hours and hr$number_project
## 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
ggplot(hr, aes(x = number_project, y = average_montly_hours)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, color = "purple") +
labs(title = "More projects will result in more average monthly hours",
x = "Number Of Projects",
y = "Average Monthly Hours")
## `geom_smooth()` using formula = 'y ~ x'

P-value interpretation: The P value shows that the correlation is
statistically significant.
Correlation estimate interpretation: The correlation is moderately
positive.
Non-technical interpretation: More projects will result in more
average monthly hours.
Correlation Three
cor.test(hr$number_project , hr$time_spend_company)
##
## Pearson's product-moment correlation
##
## data: hr$number_project and hr$time_spend_company
## t = 24.579, df = 14997, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.1813532 0.2121217
## sample estimates:
## cor
## 0.1967859
ggplot(hr, aes(x = time_spend_company, y = number_project)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, color = "purple") +
labs(title = "More time spent at the company increases the number of projects",
x = "Time Spend Company",
y = "Number Of Projects")
## `geom_smooth()` using formula = 'y ~ x'

P-value interpretation: The P value shows that the correlation is
statistically significant.
Correlation estimate interpretation: The correlation is a weak
positive relationship.
Non-technical interpretation: Generally the more time is spent at
the company the number of projects increases.
Correlation Four
cor.test(hr$average_montly_hours , hr$time_spend_company)
##
## Pearson's product-moment correlation
##
## data: hr$average_montly_hours and hr$time_spend_company
## t = 15.774, df = 14997, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.1119801 0.1434654
## sample estimates:
## cor
## 0.1277549
ggplot(hr, aes(x = time_spend_company, y = average_montly_hours)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, color = "purple") +
labs(title = "Average monthly hours generally go up as time spent increases",
x = "Time Spend Company",
y = "Average Monthly Hours")
## `geom_smooth()` using formula = 'y ~ x'

P-value interpretation: The P value shows that the correlation is
statistically significant.
Correlation estimate interpretation: The correlation is a weak
positive relationship.
Non-technical interpretation: Average monthly hours generally go up
as time spent at the company increases.