s-news
[Top] [All Lists]

Re: Merging Time Series

To: "Henrik Aalborg Nielsen" <immhan@student.dtu.dk>, "Horace Tso" <Horace_Tso@pgn.com>
Subject: Re: Merging Time Series
From: "Pope, Alun" <Alun.Pope@apra.gov.au>
Date: Fri, 20 Jun 2003 17:26:40 +1000
Cc: "s-news-list" <s-news@lists.biostat.wustl.edu>
Thread-index: AcM2/Frf9EjKsmgDSom9y8j5WqQ48AAALYXQ
Thread-topic: [S] Merging Time Series
Henrik

Thanks for this.  Wouldn't it be nice if the help pointed from timeSeries to 
seriesMerge? 

Alun

____________________
Dr Alun Pope

Statistics Consultant
Australian Prudential Regulation Authority
400 George Street, Sydney NSW 2000, Australia
GPO Box 9836, Sydney NSW 2001, Australia

Tel: (02) 9210 3232
Fax: (02) 9210 3021
E-mail: alun.pope@apra.gov.au


-----Original Message-----
From: Henrik Aalborg Nielsen [mailto:immhan@student.dtu.dk] 
Sent: Friday, 20 June 2003 5:18 PM
To: Horace Tso
Cc: s-news-list
Subject: Re: [S] Merging Time Series

Dear Horace,

seriesMerge should do the job :

> tmp <- timeSeries(data=data.frame(x=1:10))
> tmp2 <- timeSeries(data=data.frame(x=11:20))
>  seriesMerge(tmp, tmp2)
  Positions x.1 x.2
 01/01/1960  1  11
 01/02/1960  2  12
 01/03/1960  3  13
 01/04/1960  4  14
 01/05/1960  5  15
 01/06/1960  6  16
 01/07/1960  7  17
 01/08/1960  8  18
 01/09/1960  9  19
 01/10/1960 10  20
>

Regards,
Henrik

--------------------------------------------------------------------------
   Henrik Aalborg Nielsen                  
   Informatics and Mathematical Modelling
   Section for Statistics, Time Series Group
   Technical University of Denmark
   Richard Petersens Plads, Build.321,
   DK-2800 Kgs. Lyngby, Denmark.
   Phone:  +45 4525 3418
   Fax.:   +45 4588 2673
   E-mail: han@imm.dtu.dk
   URL:    http://www.imm.dtu.dk/~han
--------------------------------------------------------------------------

On Thu, 19 Jun 2003, Horace Tso wrote:

> Hi folks,
> 
> Using 6.1 under Win2K, I want to do a Union of two Time Series. Sounds 
> simple? I've tried every trick out there and nothing works. SPlus support 
> suggests using merge(), but that doesn't work. Each series has identical 
> column names, Y1, Y2, Y3. There are some overlapping dates in both. Here they 
> are, 
> 
> > t1
> Position    Y1    Y2      Y3
> 02/12/1997 7.00  6.50 7.50 
> 02/26/1997 6.50  6.25 6.75 
> 02/27/1997 6.50  6.25 6.75
> 02/28/1997 6.50  6.25 6.75
> 03/01/1997 6.50  6.25 6.75
> 03/03/1997 6.50  6.25 6.75
> 03/04/1997 9.21  7.25 10.00
> 03/05/1997 10.00 9.75  10.25
> 03/06/1997 8.75  8.50  9.00
> 
> >t2
> Position    Y1    Y2      Y3
> 02/12/1997 6.00  8.50 7.50 
> 02/26/1997 6.15  6.00 6.75 
> 02/27/1997 4.50  4.25 4.75
> 02/28/1997 3.50  3.25 3.25
> 03/01/1997 6.50  6.25 6.75
> 03/04/1997 6.50  6.25 6.75
> 03/05/1997 1.21  2.25 1.00
> 03/08/1997 1.00  0.75  0.25
> 03/09/1997 2.25  2.50  2.00
> 
> I want to create the following,
> 
> Position         Y1    Y2      Y3    Y11    Y21    Y31
> 02/12/1997  6.00  8.50 7.50  7.00   6.50   7.50
> 02/26/1997  6.15  6.00 6.75  6.50   6.25   6.75
> 02/27/1997  4.50  4.25 4.75  6.50   6.25    6.75
> 02/28/1997  3.50  3.25 3.25  6.50   6.25    6.75
> 03/01/1997  6.50  6.25 6.75  6.50   6.25    6.75
> 03/03/1997  NA     NA   NA     6.50   6.25    6.75
> 03/04/1997  6.50  6.25 6.75   9.21  7.25   10.00
> 03/05/1997  1.21  2.25 1.00  10.00 9.75   10.25
> 03/06/1997  NA     NA   NA     8.75    8.50   9.00
> 03/08/1997  1.00  0.75   0.25 NA     NA      NA
> 03/09/1997  2.25  2.50   2.00 NA     NA      NA
> 
> Thanks a lot.
> 
> Horace W. Tso
> Senior Quantitative Analyst
> Portland General Electric
> Portland, Oregon
> 503-464-8430 (D)
> 

--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu.  To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message:  unsubscribe s-news


IMPORTANT NOTICE:

This e-mail is intended solely for the person or organisation to whom it is
addressed, and may contain secret, confidential or legally privileged
information. 

If you have received this e-mail in error or are aware that you are not
authorised to have it, you MUST NOT use or copy it, or disclose its contents
to any person. If you do any of these things, you may be sued or prosecuted.

If you have received this e-mail in error, please contact the sender
immediately. 

<Prev in Thread] Current Thread [Next in Thread>