我有一个像这样的json文件:
[
{"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}
]
我想计算使用 D3 js 编程的值的平均值,我可以得到它的总平均值,如下所示:
function meanVak(value) {
return d3.mean(data, function(d) {return d [value] })
}
var meanProgramming = meanVak('programming');
但是现在我想要一个基于性别的“编程”的单独平均值。所以对于女性和男性。我该怎么做?