collegeDistance <- read.csv("https://vincentarelbundock.github.io/Rdatasets/csv/AER/CollegeDistance.csv", header = TRUE)
highIncomeMale <- subset(collegeDistance,gender=="male" & income == "high")
highIncomeMale$state <-"New York"
highIncomeMale$state <-"New York"
highIncomeMale$city <-"Brooklyn"
# for all the education field values that are 16, change the state field value to New Jersey.
highIncomeMale$state[highIncomeMale$education == 16]<-"New Jersey"
#I will display the first twenty rows of the modified data frame subset
head(highIncomeMale,20)
## X gender ethnicity score fcollege mcollege home urban unemp wage distance
## 1 1 male other 39.15 yes no yes yes 6.2 8.09 0.2
## 22 22 male other 59.56 yes no yes no 7.7 7.04 0.5
## 33 33 male other 58.66 yes no yes yes 5.1 8.85 0.5
## 38 38 male other 61.03 yes no no no 6.2 8.09 0.6
## 39 39 male other 54.35 no no no no 6.2 8.09 0.6
## 41 41 male other 70.10 yes no yes no 6.2 8.09 0.6
## 61 61 male other 57.74 no no yes no 5.5 8.09 1.5
## 62 62 male other 60.38 yes no yes no 5.5 8.09 1.5
## 63 63 male other 62.77 no no no no 5.5 8.09 1.5
## 70 70 male other 53.21 no no yes no 6.9 7.04 2.0
## 74 74 male other 60.22 yes no yes no 7.7 7.04 2.0
## 77 77 male other 51.84 yes yes no no 4.4 8.09 0.5
## 80 80 male other 57.50 no yes yes no 4.4 8.09 0.5
## 82 82 male other 50.62 yes no yes no 7.5 8.09 0.5
## 97 97 male other 56.47 yes no yes no 5.3 8.09 0.1
## 105 105 male other 66.95 yes yes yes no 6.1 7.69 2.5
## 112 112 male other 44.46 yes yes yes no 5.4 8.09 1.9
## 117 117 male hispanic 38.95 no no yes no 13.5 7.69 5.0
## 122 122 male other 44.46 no no yes no 8.7 8.85 1.5
## 127 127 male other 52.74 yes no yes no 6.5 8.09 0.8
## tuition education income region state city
## 1 0.88915 12 high other New York Brooklyn
## 22 0.90300 14 high other New York Brooklyn
## 33 0.84988 16 high other New Jersey Brooklyn
## 38 0.88915 14 high other New York Brooklyn
## 39 0.88915 15 high other New York Brooklyn
## 41 0.88915 17 high other New York Brooklyn
## 61 0.88915 16 high other New Jersey Brooklyn
## 62 0.88915 12 high other New York Brooklyn
## 63 0.88915 12 high other New York Brooklyn
## 70 0.90300 18 high other New York Brooklyn
## 74 0.90300 12 high other New York Brooklyn
## 77 0.88915 18 high other New York Brooklyn
## 80 0.88915 12 high other New York Brooklyn
## 82 0.88915 14 high other New York Brooklyn
## 97 0.88915 13 high other New York Brooklyn
## 105 1.11201 16 high other New Jersey Brooklyn
## 112 0.88915 12 high other New York Brooklyn
## 117 1.11201 13 high other New York Brooklyn
## 122 0.84988 12 high other New York Brooklyn
## 127 0.88915 12 high other New York Brooklyn