---
title: "assignment 7"
author: "Lily Woodward"
date: "2026-03-24"
output: html_document
---
``` r
library(readr)
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$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
The p-value is less than 0.05, so the correlation is statistically significant. The correlation is positive and moderate, meaning there is a moderate positive relationship between number of projects and average monthly hours.
Employees who work on more projects tend to spend more hours working each month.
ggplot(hr, aes(x = number_project, y = average_montly_hours)) +
geom_point(alpha = 0.4) +
geom_smooth(method = "lm", se = FALSE, color = "red") +
labs(
title = "Employees With More Projects Tend to Work More Hours",
x = "Number of Projects",
y = "Average Monthly Hours"
)
## `geom_smooth()` using formula = 'y ~ x'
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
The p-value is less than 0.05, so the correlation is statistically significant. The correlation is very weak and positive, meaning there is a relationship between satisfaction level and last evaluation scores.
Employees who are more satisfied with their jobs tend to have higher performance evaluation scores.
ggplot(hr, aes(x = satisfaction_level, y = last_evaluation)) +
geom_point(alpha = 0.4) +
geom_smooth(method = "lm", se = FALSE, color = "red") +
labs(title = "Employees with Higher Satisfaction Tend to Have Better Evaluations",
x = "Satisfaction Level",
y = "Last Evaluation Score")
## `geom_smooth()` using formula = 'y ~ x'
cor.test(hr$time_spend_company, hr$average_montly_hours)
##
## Pearson's product-moment correlation
##
## data: hr$time_spend_company and hr$average_montly_hours
## 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
The p-value is less than 0.05, so the correlation is statistically significant. The correlation is positive, meaning there is a positive relationship between time spent at the company and average monthly hours.
Employees who have been at the company longer tend to work more hours each month.
ggplot(hr, aes(x = time_spend_company, y = average_montly_hours)) +
geom_point(alpha = 0.4) +
geom_smooth(method = "lm", se = FALSE, color = "red") +
labs(title = "Employees Who Stay Longer Tend to Work More Hours",
x = "Time Spent at Company",
y = "Average Monthly Hours")
## `geom_smooth()` using formula = 'y ~ x'
cor.test(hr$number_project, hr$last_evaluation)
##
## 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
The p-value is less than 0.05, so the correlation is statistically significant. The correlation is positive, meaning there is a positive relationship between number of projects and last evaluation scores.
Employees who work on more projects tend to have higher evaluation scores.
ggplot(hr, aes(x = number_project, y = last_evaluation)) +
geom_point(alpha = 0.4) +
geom_smooth(method = "lm", se = FALSE, color = "red") +
labs(title = "Employees With More Projects Tend to Have Higher Evaluations",
x = "Number of Projects",
y = "Last Evaluation Score")
## `geom_smooth()` using formula = 'y ~ x'