[R-SIG-Finance] stripping holidays from timeSeries() class time series

David-Michael Lincke dlincke at lincke.com
Wed May 9 22:15:55 CEST 2012


Turns out that the following accomplishes the same:

tsm[-which(as.Date(time(tsm)) %in% as.Date(index.holidays)),]

However, I still wonder if there is not a more elegant way to achieve this while remaining within the timeDate/timeSeries classes.

________________________________________
From: r-sig-finance-bounces at r-project.org [r-sig-finance-bounces at r-project.org] on behalf of David-Michael Lincke [dlincke at lincke.com]
Sent: Wednesday, May 09, 2012 21:33
To: r-sig-finance at r-project.org
Subject: [R-SIG-Finance] stripping holidays from timeSeries() class time        series

I have come up with the following expression to strip a time series tsm of class timeSeries from holidays contained in timeDate class object index.holidays. index.holidays covers a wider date range than time series tsm.

tsm[-na.omit(match(as.character(index.holidays),as.character(time(tsm)))),]

While this expression works as intended, I suspect that it is rather inefficient due to the data type conversions forced by match(). Is there a more elegant way to accomplish this?

Best regards,
David

        [[alternative HTML version deleted]]

_______________________________________________
R-SIG-Finance at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.



More information about the R-SIG-Finance mailing list