library(tidyr)
library(readr)
library(ggplot2)
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
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.
##q1
q8_1 <- t.test(hr$satisfaction_level, hr$last_evaluation)
q8_1
##
## Welch Two Sample t-test
##
## data: hr$satisfaction_level and hr$last_evaluation
## t = -41.899, df = 26607, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.10809919 -0.09843725
## sample estimates:
## mean of x mean of y
## 0.6128335 0.7161017
#q2 #the p value of zero inficates a significant difference between the mean valued of satisfaction level and last evaluation
#q3 #the reslts mean there is a meaningful sidderence between average satisfaction level and average last evaluation scores among employees
#q4
data_long <- hr %>%
select(satisfaction_level, last_evaluation) %>%
pivot_longer(cols = everything(), names_to = "variable", values_to = "score")
ggplot(data_long, aes(x = variable, y = score, fill = variable)) +
geom_boxplot() +
stat_summary(fun = mean, geom = "point", shape = 18, size = 3, color = "red") +
labs(
title = "Difference in Average Satisfaction and Evaluation Scores",
x = "Variable",
y = "Score"
) +
theme_minimal() +
theme(legend.position = "bottom") +
scale_fill_manual(values = c("skyblue", "salmon"))