I have seen other posts regarding this issue. I followed them.
The code I am using to convert a double array to a double vector is-
cppFunction("
std::vector<double> ArrayToVector(double *arr){
std::vector<double> vec(arr, arr+ sizeof(arr)/sizeof(arr[0]));
return vec;
}
")
But I am getting this error:
file52e20f14d34.cpp:28:52: error: cannot initialize a variable of type 'Rcpp::traits::input_parameter<double>::type *' (aka 'InputParameter<double> *') with an lvalue of type 'SEXP' (aka 'SEXPREC *')
Rcpp::traits::input_parameter< double >::type *arr(*arrSEXP);
^ ~~~~~~~~
1 error generated.
make: *** [file52e20f14d34.o] Error 1
clang++ -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I"/private/var/folders/4w/v4pl36r9475cb2fkspc3qxkm0000gp/T/RtmpSXqByM/sourceCpp-x86_64-apple-darwin15.6.0-1.0.1" -I/usr/local/include -fPIC -Wall -g -O2 -c file52e20f14d34.cpp -o file52e20f14d34.o
Error in sourceCpp(code = code, env = env, rebuild = rebuild, cacheDir = cacheDir, :
Error 1 occurred building shared library.
Can anyone explain me why this is happening? Any help would be much appreciated.