In this assignment, you will analyze employee attrition data using t-tests and visualization techniques in R. You will perform a t-test, interpret the results, both in technical and in non-technical terms, and create the appropriate graph.
The dataset contains information about employees, including their satisfaction levels, last evaluation scores, number of projects, average monthly hours, time spent at the company, work accidents, promotion history, department, and salary.
Perform four (4) t-tests using any appropriate variables
(continuous) by the variable left. Note that the variable
left describes whether the employee left the company
(left = 1), or not (left = 0).
For each of the four t-tests:
Perform the t-test (.5 point) Choose any two appropriate variables from the data and perform the t-test, displaying the results.
Interpret the results in technical terms (.5 point) For each t-test, explain what the test’s p-value means (significance).
Interpret the results in non-technical terms (1 point) For each t-test, what do the results mean in non-techical terms.
Create a plot that helps visualize the t-test (.5 point) For each t-test, create a graph to help visualize the difference between means, if any. The title must be the non-technical interpretation.
Submit your assignment by providing a link to your published RPubs document containing all the required visualizations and explanations.
Total: 10 points
Use this code to read the data. Note that you will need additional libraries
library(readr)
hr <- read_csv('https://raw.githubusercontent.com/aiplanethub/Datasets/refs/heads/master/HR_comma_sep.csv')
t.test(mtcars$mpg ~ mtcars$am)
##
## Welch Two Sample t-test
##
## data: mtcars$mpg by mtcars$am
## t = -3.7671, df = 18.332, p-value = 0.001374
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
## -11.280194 -3.209684
## sample estimates:
## mean in group 0 mean in group 1
## 17.14737 24.39231
p-value interpretation: The p-value is very small, therefore the difference between means of mpg by am is significant.
t-test interpretation: The difference in mean MPG between manual and automatic cars is significant, where the difference in MPG is at least 3.2 MPG.
non-technical interpretation: Manual cars are more fuel efficiency
library(plotly)
library(dplyr)
plot_data <- mtcars %>%
mutate(Transmision = as.factor(ifelse(am == 0 , 'Automatic' , 'Manual')))
plot_ly(plot_data ,
x = ~Transmision ,
y = ~mpg ,
type = 'box')
Good luck!