Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 R xts 时间序列。如何从中创建一个新的时间序列,其中包含原始数据中的所有数据,但周一 12:00 到 18:00 之间发生的数据点除外?
这是一种方法。
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)),]
如果您只需要 12:00-18:00 之间的时间,您可以像这样使用 xts-subsetting:
x["T12:00/T18:00"]