s-news
[Top] [All Lists]

Re: inverting a timeDate sequence

To: "Paul H. Lasky" <phlasky@earthlink.net>, "SPlus-News" <s-news@wubios.wustl.edu>
Subject: Re: inverting a timeDate sequence
From: "Jeffrey Wang" <jwang@xcaliber.com>
Date: Tue, 16 Sep 2003 14:42:49 -0500
Thread-index: AcN8ieK8Y9dtMWt+R82ANXDM1tkfZQAAMNvA
Thread-topic: [S] inverting a timeDate sequence
    timeDate objects are stored internally as a list of integers. You can 
reverse them by:

> td@.Data[[1]] = rev(td@.Data[[1]])
> td@.Data[[2]] = rev(td@.Data[[2]])

----
Jeffrey Wang
Ronin Capital LLC
Chicago, IL 60604
Tel: (312) 244-5768
Fax: (312) 244-5836 
-----Original Message-----
From: Paul H. Lasky [mailto:phlasky@earthlink.net]
Sent: Tuesday, September 16, 2003 2:36 PM
To: SPlus-News
Subject: [S] inverting a timeDate sequence


    How do you create a timeDate sequence with the latest date as the first 
element and oldest date the last element, AND exclude weekends (utilizing Splus 
6.1)?  The following efforts were unsuccessful:

   td = timeSeq(from="9/15/2003", to = "4/15/2003", by=-"bizdays")

   td = timeSeq(from="9/15/2003", to="4/15/2003", by = "bizdays")

or
 td1 = timeSeq(from="4/15/2003", to"9/15/2003", by="bizdays")
td = -sort(-td1)  [ sort does not work with timeDate sequences]

Is it really necessary to inelegantly process td1 in a for loop   --- which 
does work ? e.g.

  td = td1
  for( i in 1:length(td1) )  td[ length(td1) -i +1 ] = td1[ i ] }

Incidentally this is a very slow processing.

Paul H. Lasky
B & P Consultants
Rancho Santa Fe, CA
      

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