Dear Paul,
Maybe the following function is helpful - it concats timeSeries or
signalSeries directly:
seriesConcat <- function(..., list.series = list(...))
{
##
## Concats the series in ... or list.series. The argument
## list.series must be written in full if used.
## The function works for timeSeries and signalSeries.
## Author: han@imm.dtu.dk
elemClass <- unlist(lapply(list.series, class))
if(any(elemClass[1] != elemClass))
stop("All arguments must be of the same class")
elemClass <- elemClass[1]
pos <- do.call("concat", lapply(list.series, positions))
if(!is.null(dim(seriesData(list.series[[1]])))) bindMethod <- "rbind"
else bindMethod <- "c"
data <- do.call(bindMethod, lapply(list.series, seriesData))
z <- do.call(elemClass, list(positions = pos, data = data))
return(z)
}
The function could be used to make concat() work by writing a method for
concat.two().
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 Mon, 23 Jun 2003, Paul H. Lasky wrote:
> There is no "c" or concetration function for timeDate objects. And the append
> function cannot be used to splice together two timeDate sequences. How then
> do you build irregular time series, e.g. how do you build a daily sequence
> that avoids the 9/11/01 shutdown dates at the NYSE and other exchanges?
>
> I discovered an easy way that works for version 6.0 or 6.1 on any Windows
> 98 or later system. To splice together two timeDate objects say td1 and td2
> use the following function:
>
> # ----------------Concetrate TimeDates------------
> # This function allows the creation of irregular timeDate
> # sequences without tears.
> c. time <- function(td.one,td.two)
> {
> tda <- append(td.one, td.two)
> dates(append(tda[[ 1]] [[ 1]], tda[[ 6 ]] [[ 1 ]]
> }
>
> Thus to create a timedate sequence of only the trading days for 2001 you
> cannot simply use the holiday.NYSE and bizdays functions because they do not
> include the abrupt shutdown of the trading caused by the catastrophe. Here's
> how you do it:
>
> td.one <- timeSeq(from = "1/2/01", to = "9/10/01", by = "bizdays",
> holidays = holiday.NYSE(2001) )
>
> td.two <- timeSeq(from = "9/17/01", to = "12/31/01", by = "bizdays",
> holidays = holiday.NYSE(2001) )
>
> td <- c.time(td.one, td.two)
>
> Paul H. Lasky
> P & B Consultants
|