I'm newbie in Rcpp, but I have a task which's connected with Date and Datetime. Let me have market data in DataFrame in my Rcpp function. So, Date field has formatting like this:
2016-04-19 00:01:00
Dataframe field name which contains Date values is "Date". So, I get 2 vectors:
DatetimeVector datetime = df["Date"];
DateVector pureDate = df["Date"];
Problems:
1) I can't take difference between 2 Date values of Date (I don't know why, but gcc-4.9.3 gives me an error on difference like this:
Date pureDay = pureDate[0];
auto tmp = pureDate[j+1] - pureDay;
error: ambiguous overload for 'operator-' (operand types are 'Rcpp::traits::storage_type<14>::type {aka double}' and 'Rcpp::Date') auto tmp = tmpDate[j+1] - tmpTradeDay;
But if I use code like this:
Date pureDay = pureDate[0];
auto tmp = pureDate[j+1] - pureDate[j];
It works well.
2) How it possible to format an output for Date
and Datetime
objects? to_string
won't format it well - I give a result like this: 1461176460.000000
3) I expected that syntax like Date(datetime[i])
will give me a Date
object. But it won't. I know that pureDate[1] - pureDate[0]
should have the same Y-M-D
value, but they differ for series lag (60 seconds).
Thnxs. Could anyone helps me with these problems?