s-news
[Top] [All Lists]

Re: inverting a timeDate sequence Summary of Replies

To: "SPlus-News" <s-news@wubios.wustl.edu>
Subject: Re: inverting a timeDate sequence Summary of Replies
From: "Paul H. Lasky" <phlasky@earthlink.net>
Date: Thu, 18 Sep 2003 10:19:42 -0700
References: <001101c37c89$d318fda0$b2b7b2d1@ELNphlasky>
    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]
 
  Thanks to Jeffrey Wang, Chuck Taylor, Tony Plate, James Holman, and Nick Ellis for helpful replies.  There are 3 ways to easily invert or reverse a timeDate sequence:
 
  The most direct way is simply to :
  1)  td = td1[ length(td1): 1 ], where td is the reversed sequence and td1 the forward sequence. 
 
  2) Nick Ellis pointed out another direct way:
 
    td=timeSeq(from="9/15/2003", to "4/15/2003, by = "bizdays", k.by = -1)
 [ it always helps to read the language reference thoroughly...]
 
 3) Finally you can use the rev function:
   td = rev(td1)
  
 
Paul H. Lasky
B & P Consultants
Rancho Santa Fe, CA
      
 
<Prev in Thread] Current Thread [Next in Thread>