I have got a json file like so:
[
{"id":1,"sex":"Female","programming":5, "project":7},
{"id":2,"sex":"Male","programming":8, "project":4},
{"id":3,"sex":"Female","programming":5, "project":6},
{"id":4,"sex":"Male","programming":4, "project":7}
]
I want to calculate the mean of the value’s of programming with D3 js
I can get the total mean of it like so:
function meanVak(value) {
return d3.mean(data, function(d) {return d [value] })
}
var meanProgramming = meanVak('programming');
But now i want a separate mean for ‘programming’ based on sex. So for female and male.
How should i do that?
1 Answer