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.
str(hr)
## spc_tbl_ [14,999 × 10] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
## $ satisfaction_level : num [1:14999] 0.38 0.8 0.11 0.72 0.37 0.41 0.1 0.92 0.89 0.42 ...
## $ last_evaluation : num [1:14999] 0.53 0.86 0.88 0.87 0.52 0.5 0.77 0.85 1 0.53 ...
## $ number_project : num [1:14999] 2 5 7 5 2 2 6 5 5 2 ...
## $ average_montly_hours : num [1:14999] 157 262 272 223 159 153 247 259 224 142 ...
## $ time_spend_company : num [1:14999] 3 6 4 5 3 3 4 5 5 3 ...
## $ Work_accident : num [1:14999] 0 0 0 0 0 0 0 0 0 0 ...
## $ left : num [1:14999] 1 1 1 1 1 1 1 1 1 1 ...
## $ promotion_last_5years: num [1:14999] 0 0 0 0 0 0 0 0 0 0 ...
## $ Department : chr [1:14999] "sales" "sales" "sales" "sales" ...
## $ salary : chr [1:14999] "low" "medium" "medium" "low" ...
## - attr(*, "spec")=
## .. cols(
## .. satisfaction_level = col_double(),
## .. last_evaluation = col_double(),
## .. number_project = col_double(),
## .. average_montly_hours = col_double(),
## .. time_spend_company = col_double(),
## .. Work_accident = col_double(),
## .. left = col_double(),
## .. promotion_last_5years = col_double(),
## .. Department = col_character(),
## .. salary = col_character()
## .. )
## - attr(*, "problems")=<externalptr>
cor_test_1 <- cor.test(hr$satisfaction_level, hr$last_evaluation)
Technical Interpretation: The p-value in this correlation test indicates whether there is a statistically significant relationship between satisfaction level and last evaluation. A p-value below 0.05 would confirm significance, suggesting that the observed relationship between these variables is unlikely to be due to chance. The correlation coefficient, which ranges from -1 to 1, shows the strength and direction of the relationship. Here, a positive correlation suggests that as satisfaction level increases, last evaluation scores also increase.
Non-Technical Interpretation: If there is a significant positive correlation, we can interpret it as: “Employees who report higher satisfaction levels tend to receive higher performance evaluations.”
ggplot(hr, aes(x = satisfaction_level, y = last_evaluation)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, color = "blue") +
labs(title = "Higher Satisfaction, Higher Evaluation",
x = "Satisfaction Level",
y = "Last Evaluation Score")
## `geom_smooth()` using formula = 'y ~ x'
cor_test_2 <- cor.test(hr$number_project, hr$average_montly_hours)
Technical Interpretation: The p-value here tells us if the relationship between the number of projects and average monthly hours is statistically significant. A small p-value (e.g., < 0.05) would confirm that the relationship is unlikely to be random. The correlation coefficient value will indicate the strength and direction of the relationship, with a positive coefficient suggesting that more projects are associated with more hours worked.
Non-Technical Interpretation: A positive correlation might be interpreted as: “Employees who take on more projects tend to work longer hours each month.”
ggplot(hr, aes(x = number_project, y = average_montly_hours)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, color = "green") +
labs(title = "More Projects, More Monthly Hours",
x = "Number of Projects",
y = "Average Monthly Hours")
## `geom_smooth()` using formula = 'y ~ x'
cor_test_3 <- cor.test(hr$time_spend_company, hr$last_evaluation)
Technical Interpretation: The p-value for this correlation tells us if there is a statistically significant relationship between the time spent at the company and the last evaluation score. If the p-value is small (below 0.05), it suggests a meaningful relationship. The correlation coefficient describes the strength and direction of this association; a positive coefficient means that employees with longer tenure might have higher evaluation scores.
Non-Technical Interpretation: If positively correlated, we might interpret it as: “Employees who stay with the company longer tend to have better performance evaluations.”
ggplot(hr, aes(x = time_spend_company, y = last_evaluation)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, color = "purple") +
labs(title = "Longer Tenure, Higher Evaluation",
x = "Years at Company",
y = "Last Evaluation Score")
## `geom_smooth()` using formula = 'y ~ x'
cor_test_4 <- cor.test(hr$average_montly_hours, hr$satisfaction_level)
Technical Interpretation: The p-value here tests if the correlation between average monthly hours and satisfaction level is significant. A significant p-value (below 0.05) indicates that there is likely a real relationship between the two variables. The correlation coefficient will show if this relationship is positive or negative. For example, a negative correlation would suggest that higher work hours are associated with lower satisfaction levels.
Non-Technical Interpretation: A negative correlation might mean: “Employees who work more hours each month tend to report lower satisfaction.”
ggplot(hr, aes(x = average_montly_hours, y = satisfaction_level)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, color = "red") +
labs(title = "More Hours, Less Satisfaction",
x = "Average Monthly Hours",
y = "Satisfaction Level")
## `geom_smooth()` using formula = 'y ~ x'