s-news
[Top] [All Lists]

Re: inverting a timeDate sequence

To: "SPlus-News" <s-news@wubios.wustl.edu>
Subject: Re: inverting a timeDate sequence
From: Tony Plate <tplate@blackmesacapital.com>
Date: Tue, 16 Sep 2003 14:02:44 -0600
In-reply-to: <D5C377ECA6DD12478267E89585EE642C324569@chi-mail2.win.xcali ber.com>
Reply-to: tplate@acm.org
somewhat simpler is

> rev(td)

(no need to mess around with the internals when the class fully supports the indexing operations needed)

At Tuesday 02:42 PM 9/16/2003 -0500, Jeffrey Wang wrote:
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

--------------------------------------------------------------------
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

Tony Plate   tplate@acm.org


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