Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8919113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:56:05+00:00 2026-06-15T05:56:05+00:00

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,

  • 0

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 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T05:56:06+00:00Added an answer on June 15, 2026 at 5:56 am
    // I think the easiest way is to use the d3.nest function.  Perhaps something like ... 
    var nest = d3.nest()
      .key(function(d) { return d.sex; })
      .sortKeys(d3.ascending)
      .rollup(function(d) {
        return {
          meanVakValue: d3.mean(d, function(g) { return g[value]; })
        };
      })
      .map(data);
    
    // You may then need to turn it back into entries.  I had to use map first then extract to entries
    // but I'm still getting my head around d3.
    var nestedData = d3.entries(nest);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got a JSON file with value's that got a whitespace in them. like
I'd like to ask for some help. I have an external JSON file with
I have queried yahoo finance for historic data and have got JSon output. What
(I am using json with PHP) Hi i have got a url, from some
I have a list of places in listview which i got from parsing JSON.
Have got an NSString *str = @12345.6789 and want to find out if there
I have got the requirement to find the core file in multiple box/machine and
I've got a model creation form in rails which I also have returning JSON
Okay I have a JSON file and it has a set of objects that
I have a Django that having API for JSON, and I want it to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.