Using R data.table for a subset of high-frequency time series (replacing xts functionality with data.table)

I would like to have all the data between a certain time every day using data.table.

Is this the most efficient (in speed and memory) way of such a subset?

R.data.table <- data.table(Time = Sys.time() + 1:86400, runif(86400))

R.data.table[Time > as.POSIXct('2016-09-18 08:00:00') & Time < as.POSIXct('2016-09-18 09:00:00')]

I know that I can use xts, but I like working with data.table because I could use these datasets for prediction models, so I do not need to convert.

I looked at data.tableon IDateand ITimenot know how to assemble it all. Is it faster and easier to work with them online?

For operations such as, for example, I do not ask how to do this directly ... provide me with all the data for the last 2 working days of each month, all working hours. Does this, like I above, make the most efficient way to do this, or are there better ways to manipulate time series with data tables in R?

+7
source share
1 answer

Does this, like I above, make the most efficient way to do this, or are there better ways to manipulate time series with data tables in R?

( ) between . , , , , . , devel CRAN- ( ). between , , , /, . , , .

library(data.table)
d = data.table(Time = as.POSIXct("2016-09-18 06:00:00") + 1:86400, runif(86400))
dn = as.POSIXct('2016-09-18 08:00:00')
up = as.POSIXct('2016-09-18 09:00:00')
d[Time > dn & Time < up]
d[between(Time, dn, up, incbounds=FALSE)]
d[.(dn=dn, up=up), on=.(Time>dn, Time<up)]

data.table IDate ITime, , . ?

. I Integer. , , , POSIXct , . . , .


datetime: date/datetime ( ns..) https://github.com/Rdatatable/data.table/issues/1451


: - https://github.com/Rdatatable/data.table/issues/3453, , data.table , , , xts, .

+1

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


All Articles