Meh
Meh

Reputation: 7176

How do remove data from a certain weekday period from a R time-series?

I have a R xts timeseries. How can I create a new timeseries from it, which contains all the data from the original, except the data points occurring on Monday between 12:00 and 18:00?

Upvotes: 3

Views: 1250

Answers (1)

Joshua Ulrich
Joshua Ulrich

Reputation: 176688

Here's one way to do it.

x <- .xts(rnorm(100), as.POSIXct("2011-01-06 10:00:00")-100:1*3600)
x[with(as.POSIXlt(index(x)), !(wday==1 & hour > 12 & hour < 18)),]

And if you only need the times between 12:00-18:00 you can use xts-subsetting like this:

x["T12:00/T18:00"]

Upvotes: 5

Related Questions