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(ggplot2)
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.
cor.test(hr$average_montly_hours, hr$satisfaction_level)
##
## 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
ggplot(hr, aes(x = average_montly_hours, y = satisfaction_level)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, color = "blue") +
labs(title = "Scatter Plot: Average Monthly Hours vs Satisfaction Level",
x = "Average Monthly Hours",
y = "Satisfaction Level")
## `geom_smooth()` using formula = 'y ~ x'
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
ggplot(hr, aes(x = time_spend_company, y = satisfaction_level)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, color = "blue") +
labs(title = "Scatter Plot: Time Spend at Company vs Satisfaction Level",
x = "Time Spend at Company",
y = "Satisfaction Level")
## `geom_smooth()` using formula = 'y ~ x'
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
ggplot(hr, aes(x = number_project, y = satisfaction_level)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, color = "blue") +
labs(title = "Scatter Plot: Number of Projects vs Satisfaction Level",
x = "Number of Projects",
y = "Satisfaction Level")
## `geom_smooth()` using formula = 'y ~ x'
cor.test(hr$Work_accident, hr$satisfaction_level)
##
## Pearson's product-moment correlation
##
## data: hr$Work_accident and hr$satisfaction_level
## t = 7.2006, df = 14997, p-value = 6.279e-13
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.04273358 0.07463094
## sample estimates:
## cor
## 0.05869724
ggplot(hr, aes(x = Work_accident, y = satisfaction_level)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, color = "blue") +
labs(title = "Scatter Plot: Work Accidents vs Satisfaction Level",
x = "Work Accidents",
y = "Satisfaction Level")
## `geom_smooth()` using formula = 'y ~ x'