This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.
library(readxl)
employeenumeric <- read_excel("C:/Users/Kins/Downloads/employeenumeric.xls")
read_excel("C:/Users/Kins/Downloads/employeenumeric.xls")
## # A tibble: 474 × 5
## Gender CurrentSalary YearsofEducation MinorityClassification DateofBirth
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 m 57000 15 0 19027
## 2 m 40200 16 0 21328
## 3 f 21450 12 0 10800
## 4 f 21900 8 0 17272
## 5 m 45000 15 0 20129
## 6 m 32100 15 0 21419
## 7 m 36000 15 0 20571
## 8 f 21900 12 0 24233
## 9 f 27900 15 0 16825
## 10 f 24000 12 0 16846
## # ℹ 464 more rows
library(sf)
## Linking to GEOS 3.13.1, GDAL 3.11.0, PROJ 9.6.0; sf_use_s2() is TRUE
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.2 ✔ tibble 3.3.0
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.1.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
employeefilter <- employeenumeric |>
filter(YearsofEducation == "15") |>
glimpse()
## Rows: 116
## Columns: 5
## $ Gender <chr> "m", "m", "m", "m", "f", "m", "f", "m", "f", "f…
## $ CurrentSalary <dbl> 57000, 45000, 32100, 36000, 27900, 27750, 35100…
## $ YearsofEducation <dbl> 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,…
## $ MinorityClassification <dbl> 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1,…
## $ DateofBirth <dbl> 19027, 20129, 21419, 20571, 16825, 22114, 17955…
attach(employeefilter)
t.test(CurrentSalary[Gender == "m"], CurrentSalary[Gender == "f"])
##
## Welch Two Sample t-test
##
## data: CurrentSalary[Gender == "m"] and CurrentSalary[Gender == "f"]
## t = 5.0443, df = 102.38, p-value = 1.977e-06
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 3930.779 9024.884
## sample estimates:
## mean of x mean of y
## 33527.83 27050.00
t.test(CurrentSalary[MinorityClassification == 1], CurrentSalary[MinorityClassification == 0])
##
## Welch Two Sample t-test
##
## data: CurrentSalary[MinorityClassification == 1] and CurrentSalary[MinorityClassification == 0]
## t = -2.4432, df = 59.458, p-value = 0.01755
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -6673.2519 -664.4916
## sample estimates:
## mean of x mean of y
## 28838.46 32507.33
t.test(CurrentSalary[Gender=="m" & MinorityClassification==1], CurrentSalary[Gender=="m" & MinorityClassification==0])
##
## Welch Two Sample t-test
##
## data: CurrentSalary[Gender == "m" & MinorityClassification == 1] and CurrentSalary[Gender == "m" & MinorityClassification == 0]
## t = -2.4005, df = 40.643, p-value = 0.02104
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -8164.9289 -702.7293
## sample estimates:
## mean of x mean of y
## 30055.56 34489.38
t.test(CurrentSalary[Gender=="f" & MinorityClassification==1], CurrentSalary[Gender=="f" & MinorityClassification==0])
##
## Welch Two Sample t-test
##
## data: CurrentSalary[Gender == "f" & MinorityClassification == 1] and CurrentSalary[Gender == "f" & MinorityClassification == 0]
## t = -0.62398, df = 11.646, p-value = 0.5447
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -5647.546 3139.546
## sample estimates:
## mean of x mean of y
## 26100 27354
interaction.plot(Gender, `MinorityClassification`, `CurrentSalary`)