Reputation: 2061
i want to write my own Datatype in C/C++. I generated a small class like this :
#include <Rcpp.h>
using namespace Rcpp;
class Test
{
public:
int rows;
int cols;
float a[10];
Test() {};
};
RCPP_EXPOSED_CLASS( Test )
RCPP_MODULE(mod){
class_<Test>("Test")
.constructor()
.field("rows", & Test::rows )
.field("rows", & Test::cols )
// .field("a", & Test :: a)
;
}
the code is running. But now i want to get the values from a. Ive i understand the documentation correct i have to create a "as" function ? And return a NumericVector ?
I didnt understand the SEXP type, is it a pointer that is "typeless" and can be used in C/c++ and R ?
Upvotes: 0
Views: 862
Reputation: 368241
That's a lot of somewhat elementary questions.
Maybe you should not start with a module and class? How about
std::vector<double> a
.Once a few things are more clear more doing basics, revisit the Rcpp Modules vignette.
Upvotes: 2