Exercise from Lecture 2 – Alex Crawford

GEOG 5023: Quantitative Methods In Geography

Question 1:

What are column names?

faculty <- read.csv("/Users/telekineticturtle/Desktop/Colorado 13/Quant Methods/Data/faculty.csv", 
    header = T)
names(faculty)
##  [1] "AYSALARY" "R1"       "R2"       "R7"       "PRIOREXP" "YRBG"    
##  [7] "YRRANK"   "TERMDEG"  "YRDG"     "EMINENT"  "FEMALE"

How many observations are there? How many variables?

nrow(faculty)
## [1] 725
ncol(faculty)
## [1] 11

Question 2:

Is annual salary normally distributed?
Based on the histogram constructed from the available data, the annual salary of faculty is not normally distributed. In particular, there the distribution is right-skewed.

faculty <- read.csv("/Users/telekineticturtle/Desktop/Colorado 13/Quant Methods/Data/faculty.csv", 
    header = T)
hist(faculty$AYSALARY, main = "Distribution of Faculty Salaries", xlab = "Annual Salary ($)", 
    col = "green", breaks = seq(23000, 105000, by = 2000))

plot of chunk unnamed-chunk-3

Question 3:

Does it appear that male and female faculty members make the same annual salary?
Based on the box plot constructed below, the average annual salary is higher for men than for women. They do not make the same annual salary.

boxplot(faculty$AYSALARY ~ faculty$FEMALE, main = "Annual Salary by Gender", 
    ylab = "Annual Salary ($)", xlab = "0 = Men, 1 = Women", col = rainbow(2))

plot of chunk unnamed-chunk-4

Question 4:

Does there appear to be a relationship between salary and the number of years of employment?
Based on the scatter plot below, higher salaries are correlated with longer terms of employment; R = 0.6166308

plot(faculty$AYSALARY ~ faculty$YRBG, main = "Correlation between Annual Salary and Years of Employment", 
    ylab = "Annual Salary($)", xlab = "Years of Employment", pch = 8, ylim = c(20000, 
        105000))

plot of chunk unnamed-chunk-5

cor(faculty$AYSALARY, faculty$YRBG)
## [1] 0.6166

Bonus:

Combine R1, R2, and R7; does one rank have a higher salary?
There is a clear differnce between instructors/lecturers and professors, and full professors have a higher average than associate professors.

faculty$Rank[faculty$R1 == 1] <- 1
faculty$Rank[faculty$R2 == 1] <- 2
faculty$Rank[faculty$R7 == 1] <- 3
boxplot(faculty$AYSALARY ~ faculty$Rank, main = "Annual Salary by Rank", ylab = "Annual Salary ($)", 
    xlab = "1 = Full Professor, 2 = Associate Professor, 3 = Instructor/Lecturer", 
    col = rainbow(3))

plot of chunk unnamed-chunk-6