How to remove data from a specific business day from the time series R?

I have R xs timeseries. How can I create new timers from it that contain all the data from the original, with the exception of data points occurring on Monday from 12:00 to 18:00?

+3
source share
1 answer

Here is 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 time between 12: 00-18: 00, you can use a subset of xts as follows:

x["T12:00/T18:00"]
+5
source

Source: https://habr.com/ru/post/1783887/


All Articles