I have a meteorite landings dataset.
I nested the data in four keys, by type:
var dataByType = d3.nest()
.key(function(d) {
return d.rectype;
})
.entries(dataset); // the original array
This is the resulting structure: data
Now I want to create new arrays, filtering the nested one: I want each filtered array to contain only the objects whose "mass" property is inside a defined range.
So I tried this:
// filter small meteorites
var lightWeight = dataByType.forEach(function(d){
d.values.filter(function (object) {
var mass = object.mass;
return mass <= 100;
});
});
But it returns undefined.
Nesting is giving me a lot of trouble! What do I do wrong?
Thanks in advance