Skip to content

Instantly share code, notes, and snippets.

@wush978
Created December 8, 2012 16:44
Show Gist options
  • Save wush978/4240959 to your computer and use it in GitHub Desktop.
Save wush978/4240959 to your computer and use it in GitHub Desktop.
Demo of xts API with inline
library(xts)
data(sample_matrix)
x <- as.xts(sample_matrix)
library(inline)
library(Rcpp)
f <- cfunction(sig=c(Rxts="Rxts"), Rcpp=TRUE,
includes='
extern "C" {
#define class xts_class
#include "xts.h"
#include "xts_stubs.c"
#undef class
}
', cppargs=sprintf("-I%s/include", path.package("xts")),
body='
BEGIN_RCPP
Rprintf("%d \\n", isXts(Rxts));
throw std::logic_error("test");
END_RCPP
')
f(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment