Here is the structure of a JSON file I am working with:
[
{"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}
]
To find the mean value of 'programming' using D3 js, you can calculate it like this:
function calculateMean(value) {
return d3.mean(data, function(d) {return d[value] })
}
var overallProgrammingMean = calculateMean('programming');
Now, if you want separate means for 'programming' based on sex (female and male), you can achieve that by grouping the data. Here's how you can do it: