It is an interesting topic to discuss how much the professor earn every year. Our research base on 397 professors. We have their salary, rank, discipline, years of since phd, years of service and sex information. Base on the data, we are going to find out the answer for some interesting questions.
Do professor compensate for their pay if they have more years of experience? When the pay drop? At the same time, female professor earn the same pay as their male colleague? Do those professor have higher discipline grade should earn more?
library(RCurl)
## Loading required package: bitops
x <- getURL("https://raw.githubusercontent.com/DaisyCai2019/Homework/master/Salaries.csv")
Salaries <- read.csv(text = x)
#BONUS – place the original .csv in a github file and have R read from the link
head(Salaries)
## X rank discipline yrs.since.phd yrs.service sex salary
## 1 1 Prof B 19 18 Male 139750
## 2 2 Prof B 20 16 Male 173200
## 3 3 AsstProf B 4 3 Male 79750
## 4 4 Prof B 45 39 Male 115000
## 5 5 Prof B 40 41 Male 141500
## 6 6 AssocProf B 6 6 Male 97000
tail(Salaries)
## X rank discipline yrs.since.phd yrs.service sex salary
## 392 392 Prof A 30 19 Male 151292
## 393 393 Prof A 33 30 Male 103106
## 394 394 Prof A 31 19 Male 150564
## 395 395 Prof A 42 25 Male 101738
## 396 396 Prof A 25 15 Male 95329
## 397 397 AsstProf A 8 4 Male 81035
#Data Exploration
summary(Salaries)
## X rank discipline yrs.since.phd yrs.service
## Min. : 1 AssocProf: 64 A:181 Min. : 1.00 Min. : 0.00
## 1st Qu.:100 AsstProf : 67 B:216 1st Qu.:12.00 1st Qu.: 7.00
## Median :199 Prof :266 Median :21.00 Median :16.00
## Mean :199 Mean :22.31 Mean :17.61
## 3rd Qu.:298 3rd Qu.:32.00 3rd Qu.:27.00
## Max. :397 Max. :56.00 Max. :60.00
## sex salary
## Female: 39 Min. : 57800
## Male :358 1st Qu.: 91000
## Median :107300
## Mean :113706
## 3rd Qu.:134185
## Max. :231545
Summary<-"We choose a sample of total 397 professors and the mean salary for professor is 113,706. The lowest
salary is 57,800 and highest is 231,545. The data we choose base on 39 Female professor and 358 male professor. The mean years since Phd is 22.31 and the mean years of service is 17.61. "
#2.Data wrangling:
Salaries2<-subset(Salaries,sex=='Male'& yrs.service>10 &yrs.service<18)
Salaries3<-subset(Salaries,sex=='Female'& yrs.service>10 &yrs.service<18)
summary(Salaries2)
## X rank discipline yrs.since.phd yrs.service
## Min. : 2.0 AssocProf: 5 A:17 Min. :11.00 Min. :11.00
## 1st Qu.:116.5 AsstProf : 0 B:26 1st Qu.:15.00 1st Qu.:11.00
## Median :204.0 Prof :38 Median :17.00 Median :14.00
## Mean :209.2 Mean :19.42 Mean :13.72
## 3rd Qu.:314.5 3rd Qu.:24.00 3rd Qu.:16.00
## Max. :396.0 Max. :37.00 Max. :17.00
## sex salary
## Female: 0 Min. : 81285
## Male :43 1st Qu.:106420
## Median :126431
## Mean :125038
## 3rd Qu.:143734
## Max. :173200
summary(Salaries3)
## X rank discipline yrs.since.phd yrs.service
## Min. : 64.00 AssocProf:1 A:3 Min. :11.00 Min. :11.00
## 1st Qu.: 95.25 AsstProf :0 B:5 1st Qu.:17.00 1st Qu.:13.25
## Median :285.00 Prof :7 Median :18.50 Median :14.50
## Mean :233.75 Mean :19.62 Mean :14.25
## 3rd Qu.:346.25 3rd Qu.:23.25 3rd Qu.:15.50
## Max. :362.00 Max. :28.00 Max. :17.00
## sex salary
## Female:8 Min. : 90450
## Male :0 1st Qu.:108138
## Median :110733
## Mean :117263
## 3rd Qu.:125112
## Max. :161101
head(Salaries2)
## X rank discipline yrs.since.phd yrs.service sex salary
## 2 2 Prof B 20 16 Male 173200
## 46 46 Prof B 25 15 Male 114778
## 52 52 Prof B 12 11 Male 108875
## 55 55 AssocProf B 12 11 Male 103760
## 67 67 Prof B 22 12 Male 101000
## 82 82 Prof B 17 16 Male 135585
head(Salaries3)
## X rank discipline yrs.since.phd yrs.service sex salary
## 64 64 AssocProf B 11 11 Female 103613
## 69 69 Prof B 17 17 Female 111512
## 104 104 Prof B 20 14 Female 127512
## 246 246 Prof A 17 11 Female 90450
## 324 324 Prof B 24 15 Female 161101
## 342 342 Prof B 17 17 Female 124312
Paydifference<-(125038-117263)/125038
Paydifference
## [1] 0.0621811
Summary<-"Female professor earn about 6.21% less than their male professor for the same years of service."
Salaries4<-subset(Salaries,discipline=='A')
Salaries5<-subset(Salaries,discipline=='B')
summary(Salaries4)
## X rank discipline yrs.since.phd
## Min. : 18.0 AssocProf: 26 A:181 Min. : 2.00
## 1st Qu.:140.0 AsstProf : 24 B: 0 1st Qu.:14.00
## Median :266.0 Prof :131 Median :27.00
## Mean :249.1 Mean :25.38
## 3rd Qu.:311.0 3rd Qu.:36.00
## Max. :397.0 Max. :56.00
## yrs.service sex salary
## Min. : 0.00 Female: 18 Min. : 57800
## 1st Qu.: 8.00 Male :163 1st Qu.: 83000
## Median :19.00 Median :104350
## Mean :19.95 Mean :108548
## 3rd Qu.:30.00 3rd Qu.:125192
## Max. :57.00 Max. :205500
summary(Salaries5)
## X rank discipline yrs.since.phd
## Min. : 1.00 AssocProf: 38 A: 0 Min. : 1.00
## 1st Qu.: 64.75 AsstProf : 43 B:216 1st Qu.:10.00
## Median :157.50 Prof :135 Median :18.50
## Mean :157.01 Mean :19.75
## 3rd Qu.:211.25 3rd Qu.:28.00
## Max. :356.00 Max. :56.00
## yrs.service sex salary
## Min. : 0.00 Female: 21 Min. : 67559
## 1st Qu.: 5.75 Male :195 1st Qu.: 94905
## Median :14.00 Median :113019
## Mean :15.66 Mean :118029
## 3rd Qu.:23.00 3rd Qu.:139837
## Max. :60.00 Max. :231545
Summary<-"Discipline B's average salary is $118,029, but Discipline A's average salary is only $108,548."
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.
The sample we use to evaluate the professors’ salary bases on 358 male professorsand 39 female professors. More years of service means higher pay. We also notice that except some still very high pay professors, most of the professors have a low salary rate after 30 years of services, which means they might slow down or retried. According to the data we got, male professors earn a little bit higher than their female professors. For the service between 10 to 18 years, average male professors earn 125,038 per year, but female professors only earn 117,263 per year. Female professors earn about 6.21% less than their male professors, considering the same service years. When we compare the salary for the Discipline, we have a very interesting discover. Professors who earn a higher discipline grade have a slightly lower salary.