MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Aggregating data and graphing it

  • To: mathgroup at smc.vnet.net
  • Subject: [mg101960] Re: Aggregating data and graphing it
  • From: fd <fdimer at gmail.com>
  • Date: Fri, 24 Jul 2009 06:13:36 -0400 (EDT)
  • References: <h494ve$pvq$1@smc.vnet.net>

I'd try using GatherBy, then apply a map that do the sums you want to
do e.g.

data = {{10, 1, 120}, {20, 5, 100}, {30, 7, 20}, {10, 1, 130}, {20, 7,
     134}, {10, 1, 23}, {20, 7, 68}, {30, 7, 230}, {40, 5, 235}, {10,
    1, 125}};

(* Group by elements 1 and 2 of each list*)

grpdata = GatherBy[data, #[[1]] && #[[2]] &]


(*sum by group*)

histdata = {{#[[1, 1]], #[[1, 2]]}, Total[#[[All, 3]]]} & /@ arrdata


(* histogram*)

Histogram3D[histdata]


Hope it helps






  • Prev by Date: Re: Can you do something like yield in Mathematica?
  • Next by Date: Re: documentation bug?
  • Previous by thread: Re: Aggregating data and graphing it
  • Next by thread: Re: Aggregating data and graphing it