s-news
[Top] [All Lists]

Re: Excluding dates that fall within ranges

To: s-news@lists.biostat.wustl.edu
Subject: Re: Excluding dates that fall within ranges
From: TzamouranisY@LouisDreyfus.com
Date: Thu, 18 Nov 2004 15:57:34 -0500
Hat off to James Holtman for his neat solution to this issue.

Yannis

x.flag <- lapply(1:nrow(Exclude), function(x) tab$Date >= Exclude$start[x]
& tab$Date <= Exclude$end[x])
totalEx <- do.call("|", x.flag)
new.frame <- tab[!totalEx,]

Original Question:

Hello,

I have a little date puzzle and I wonder if there is an easy way to do
solve it:
I have two tables:
One looks like this:
          Date theSignal theUnderlier
 1 01/01/1990        741   674.477138
 2 02/01/1990        729   605.619423
 3 03/01/1990        667   492.864283
 4 04/01/1990        688   296.630065
 5 05/01/1990        553   150.533697
 6 06/01/1990        336    26.129553
 7 07/01/1990        471     5.747558
 8 08/01/1990        521     5.169847
 9 09/01/1990        490    52.409640
10 10/01/1990        700   219.585063
...
The other, ExclusionDates, contains periods that I would like to drop from
the first table and  looks like this:
> ExclusionDates.df
   startDate    endDate
1 01/01/1998 06/01/1999
2 01/01/1995 04/01/1996
....

Is there an easy way to exclude  all rows from Table A that fall in any of
the ranges described in table B by the start and end dates of each row?
The numbers of rows in each table are not static and the rows in the first
table can cover a decade or two.  All dates are set at the first of the
month.
I work with SPLUS 6.2 and Finmetrics.

Thanks,

Yannis


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








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