[datatable-help] data.table and time series subsetting
Matthew Johnson
mcooganj at gmail.com
Wed Jun 13 11:19:43 CEST 2012
Data-table experts,
Thanks to this stack-overflow post
(
http://stackoverflow.com/questions/10748253/idiomatic-r-code-for-partitioning-a-vector-by-an-index-and-performing-an-operati
) i am convinced that my projects may be sped up via use of data table.
At least i hope.
I have read the introduction, and it is not clear if it is possible to do time
series sub-setting. I presently use XTS, and find that it is decently quick
for my large data sets which contain observations each second. Most
importantly XTS is robust.
My XTS sets have date/time strings that are formatted
“%Y-%m-%d %H:%M:%S”, and i wish to sub set across these:
A typical data frame might be formatted as follows:
>Names(dfx) = c(’price’, ’volume’)
>Head(dfx)
2012-06-01 09:07:34 97.55 60
2012-06-01 09:07:36 97.58 150
2012-06-01 09:07:36 97.56 10
2012-06-01 09:07:36 97.57 19
2012-06-01 09:07:39 97.58 100
2012-06-01 09:07:40 97.55 40
I would like to perform the following sub setting operations: for example,
the minute after 9:07am (on a single date or all dates); the first ten
hours on each monday; 12 to 16 on the first friday of each month; all days
in June for years 2001 to 2011; all mondays in 2008.
Additionally, i would like to sub-set such that i obtain a table showing
the volume of trades at each price on a given time interval.
For example, the printed data above would present as:
Price volume
97.55 100
97.56 10
97.57 19
97.58 250
Are such sub-setting operations possible in data.table?
I anticipate that the time series sub-setting in data.table may be more
restrictive, but as my data sets are very large and the reported speed up
relative to most methods is huge in big-data cases, i am hopeful that a
modest amount of trouble will bring large performance gains.
Is this the case?
Sorry for the long question - an answer in the affirmative and link to a
manual that i have missed would suffice.
Thanks + best regards
matt johnson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20120613/62f38e0c/attachment.html>
More information about the datatable-help
mailing list