Next, complete the following warmup exercises as a team.
var codes=_.map(data, function(college){
return college['Subject']
})
var uniqCodes=_.uniq(codes)
return _.size(uniqCodes)
They are 113 unique subject codes.
var courses=_.filter(data, function(college){
return college['CrsPBADept'] == 'CSCI'
})
return _.size(courses)
They are 63 computer science courses.
// TODO: replace with code that computes the actual result
var list=_.groupBy(data, function(college){
return college['Subject']
})
return _.mapValues(list, function(courses){
return courses.length
})
HIST | 78 |
HONR | 20 |
HUMN | 17 |
IAFS | 20 |
IPHY | 134 |
LING | 33 |
MATH | 232 |
MCDB | 117 |
BAKR | 3 |
PHIL | 160 |
PHYS | 76 |
PSCI | 117 |
NRSC | 17 |
PSYC | 123 |
WRTG | 402 |
RLST | 24 |
SLHS | 70 |
SOCY | 136 |
ARAB | 10 |
PORT | 7 |
SPAN | 162 |
COMR | 12 |
FARR | 20 |
GSAP | 3 |
INVS | 11 |
PACS | 4 |
SEWL | 8 |
DNCE | 62 |
THTR | 66 |
WMST | 29 |
ACCT | 45 |
BADM | 31 |
BCOR | 53 |
BSLW | 3 |
BUSM | 3 |
CESR | 7 |
ESBM | 24 |
FNCE | 44 |
INBU | 7 |
MBAC | 20 |
MBAX | 34 |
MGMT | 57 |
MKTG | 37 |
REAL | 12 |
EDUC | 139 |
ASEN | 48 |
CHEN | 49 |
CSCI | 63 |
AREN | 23 |
CVEN | 77 |
ECEN | 67 |
EMEN | 23 |
EHON | 5 |
GEEN | 65 |
EVEN | 2 |
HUEN | 37 |
MCEN | 90 |
TLEN | 24 |
ATLS | 44 |
MUSM | 5 |
RSEI | 2 |
JOUR | 96 |
LAWS | 176 |
CONV | 2 |
EMUS | 42 |
MUEL | 44 |
MUSC | 95 |
PMUS | 56 |
TMUS | 2 |
AIRR | 12 |
MILR | 9 |
NAVR | 9 |
CSVC | 1 |
LDSP | 14 |
NRLN | 1 |
PRLC | 3 |
ARCH | 1 |
ENVD | 59 |
ARTH | 13 |
ARTS | 52 |
CAMW | 2 |
CWCV | 1 |
LGBT | 1 |
LIBB | 6 |
CHIN | 10 |
FRSI | 1 |
HIND | 1 |
JPNS | 16 |
KREN | 3 |
ANTH | 53 |
APPM | 52 |
ASTR | 23 |
ARSC | 24 |
ATOC | 25 |
CHEM | 139 |
CLAS | 27 |
COMM | 78 |
EBIO | 113 |
ECON | 61 |
ENGL | 125 |
ENVS | 20 |
ETHN | 22 |
FILM | 33 |
FREN | 30 |
ITAL | 16 |
GEOG | 28 |
GEOL | 37 |
GRMN | 26 |
HEBR | 5 |
RUSS | 16 |
SCAN | 4 |
SWED | 1 |
LEAD | 1 |
// TODO: replace with code that computes the actual result
var groups=_.groupBy(data, function(college){
return college['Subject']
})
var coursesSize= _.mapValues(groups, function(courses){
return courses.length
})
return _.pick(coursesSize, function(size){
return size > 100
})
IPHY | 134 |
MATH | 232 |
MCDB | 117 |
PHIL | 160 |
PSCI | 117 |
PSYC | 123 |
WRTG | 402 |
SOCY | 136 |
SPAN | 162 |
EDUC | 139 |
LAWS | 176 |
CHEM | 139 |
EBIO | 113 |
ENGL | 125 |
var groups=_.groupBy(data, function(college){
return college['Subject']
})
var coursesEnroll= _.mapValues(groups, function(courses){
return _.map(courses, function(course){
return course['N']['ENROLL']
})
})
var enroll=_.mapValues(coursesEnroll, function(enrolls){
return _.sum(enrolls)
})
return _.pick(enroll, function(number){
return number > 5000
})
/*return {"IPHY": 5507,"MATH": 8725,"PHIL": 5672,"PHYS": 8099,"PSCI": 5491}*/
IPHY | 5507 |
MATH | 8725 |
PHIL | 5672 |
PHYS | 8099 |
PSCI | 5491 |
PSYC | 8477 |
WRTG | 7185 |
SOCY | 7932 |
BCOR | 6852 |
LAWS | 5166 |
// TODO: replace with code that computes the actual result
var courses=_.filter(data, function(course){
var instructor=_.filter(course['Instructors'], function(instructor){
return instructor['name'] == 'YEH, PEI HSIU'
})
return _.size(instructor) > 0
})
return _.map(courses, function(course){
return course['Course']
})
//return ['4830','4830']
They are 4830,4830.