[datatable-help] Help with using roll = TRUE ... need some variation of VLOOKUP in excel with LOCF

Santosh Srinivas santosh.srinivas at gmail.com
Thu Apr 7 12:54:22 CEST 2011


Hi All,

I am completely stuck on this and I want to do this only with
data.table! Here are the data files (click link pls): http://bit.ly/e5P5d5

I am just not able to make the roll functions work.
I have the two data sets 1) Options and 2) Futures

Please take a look at the data so that the question becomes quite easy
to understand.

The options have repeated datetimes ... and the options and futures
timestamps do not match 1 to 1

> NROW(dt_Opt_Final)
[1] 11793
> NROW(unique(dt_Opt_Final$datetime))
[1] 6292

I want to get the nearest futures price available for every option.

I believe it should be able to get my data using
dt_Fut_Final[dt_Opt_Final, roll=TRUE]
(But I tried all combinations of setkey but unable to get it to work).

I tried setting keys but I think I am losing information because the datetime
between the two datasets are absolute values but the conversion to
factors when I do setkey loses the relative information the two
datasets.

Please help!

Thanks,
Santosh


More information about the datatable-help mailing list