Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #5022 > unrolled thread

Re: List Manipulation- Advanced beginner question

Started bySseziwa Mukasa <mukasa@gmail.com>
First post2011-09-17 10:29 +0000
Last post2011-09-17 10:29 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: List Manipulation- Advanced beginner question Sseziwa Mukasa <mukasa@gmail.com> - 2011-09-17 10:29 +0000

#5022 — Re: List Manipulation- Advanced beginner question

FromSseziwa Mukasa <mukasa@gmail.com>
Date2011-09-17 10:29 +0000
SubjectRe: List Manipulation- Advanced beginner question
Message-ID<j51sqv$pff$1@smc.vnet.net>
On Sep 16, 2011, at 5:48 AM, Nguyen Van Falk wrote:

> I am trying to add multiple lists together and am looking for some
> guidance. My data is in the form of multiple time series, with dates
> that overlap one another. I need to merge the lists, add all of the
> values together  for the dates that overlap and output a single list
> that only has one entry for each date.
>
> For example, if I have three values for September 15 (8,14,10), I only
> want a single entry for September 15 in the final list with a value of
> 32. The data is in standard date spec form: { {{Date 1}, Value 1},
> {{Date 2}, Value 2},  {{Date 3}, Value 3}, ....... {{Date n}, Value
> n}, }.

My approach would be to sort the lists together, use Split to group the 
items with the same date together, then map a function over the result 
which sums up the elements in the list, for example (be warned this code 
is untested but should give you the general idea):

Total/@Split[Sort[Join[series1,series2,...]]]

Regards,
	Ssezi

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web