Next, complete the following warmup exercises as a team.
return _.size(_.compact(_.uniq(_.pluck(data, 'Subject'))))
They are 113 unique subject codes.
var dept = _.pluck(data, 'CrsPBADept')
return _.size(_.filter(dept, function(func){return func == 'CSCI'}))
They are 63 computer science courses.
var dept = _.groupBy(data, 'CrsPBADept')
return _.mapValues(dept, function(d){return d.length})
| HIST | 78 |
| HONR | 20 |
| HUMN | 17 |
| IAFS | 20 |
| IPHY | 134 |
| LING | 33 |
| MATH | 232 |
| MCDB | 117 |
| NSPC | 3 |
| PHIL | 160 |
| PHYS | 76 |
| PSCI | 117 |
| PSYC | 140 |
| PWRT | 402 |
| RLST | 24 |
| SLHS | 70 |
| SOCY | 136 |
| SPAN | 179 |
| SSPC | 58 |
| THDN | 128 |
| WMST | 29 |
| BADM | 378 |
| EDUC | 139 |
| ASEN | 48 |
| CHEN | 49 |
| CSCI | 63 |
| CVEN | 100 |
| ECEN | 67 |
| EMEN | 23 |
| ENGR | 70 |
| EVEN | 2 |
| HUEN | 37 |
| MCEN | 90 |
| TLEN | 24 |
| ATLS | 44 |
| MUSM | 5 |
| RASE | 2 |
| JOUR | 96 |
| LAWS | 176 |
| MUSC | 241 |
| ROTC | 30 |
| UGED | 19 |
| ARPL | 60 |
| AAAH | 65 |
| AHPC | 10 |
| ALAC | 31 |
| ANTH | 53 |
| APPM | 52 |
| APS | 23 |
| ARSP | 24 |
| ATOC | 25 |
| CHEM | 139 |
| CLAS | 27 |
| COMM | 78 |
| EBIO | 113 |
| ECON | 61 |
| ENGL | 125 |
| ENVS | 20 |
| ETHN | 22 |
| FILM | 33 |
| FRIT | 46 |
| GEOG | 28 |
| GEOL | 37 |
| GSLL | 52 |
// TODO: replace with code that computes the actual result
var grps = _.groupBy(data, 'Subject')
var ret = _.pick(_.mapValues(grps, function(d){
return d.length
}), function(x){
return x > 100
})
return {"IPHY": 134,"MATH": 232,"MCDB": 117,"PHIL": 160,"PSCI": 117}
| IPHY | 134 |
| MATH | 232 |
| MCDB | 117 |
| PHIL | 160 |
| PSCI | 117 |
var groups = _.groupBy(data, 'Subject')
var stuff = _.pick(_.mapValues(groups, function(d){return _.sum(_.pluck(d, 'N.ENROLL'))}, function(a){return a > 5000}))
return stuff
//console.log(stuff)
//return {"IPHY": 5507,"MATH": 8725,"PHIL": 5672,"PHYS": 8099,"PSCI": 5491}
return _.pluck(_.filter(data, function(d){
var name = _.pluck(d.Instructors, 'name')
return name == 'YEH, PEI HSIU'
}), 'Course')
//return ['4830','4830']
They are 4830,4830.