[Rcpp-devel] xts inputs and outputs for Rcpp translation
Dirk Eddelbuettel
edd at debian.org
Thu Feb 6 14:58:47 CET 2014
On 6 February 2014 at 13:29, Hideyoshi Maeda wrote:
| I was aware that an xts object is just a NumericMatrix with a few attributes and index attached, but was wondering if anybody could please give me a walkthrough example to show me how its done with some thing that has more than one column and also how one goes about subsetting columns of the xts object/matrix etc.
|
| any help as always would be greatly appreciated.
i) Pass down the xts as a SEXP to your C++ function.
ii) Instantiate a NumericMatrix from the SEXP. That would be equivalent
to coredata(myXtsObject)
iii) Pick of the attribute for the time index and instantiate a
NumericMatrix. That would be equivalent to as.numeric(index(myXtsObject)
If all that fails, separate the xts in R into coredata() and index() before
passing things down, and take it from there.
You can probably also combine i) and ii), my suggestion is untested.
Dirk
--
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
More information about the Rcpp-devel
mailing list