Re: [Rcpp-devel] How to set a default value when call a R function in Rcpp

2016-11-10 Thread Jingyu He
Hi, I've deleted the post on StackOverflow. Sorry for the ambiguity, the problem is not arg, but the Function f. #include using namespace Rcpp; // [[Rcpp::export]] RObject cppfunction(Function rfunction = NULL) { if( rfunction == NULL){ cout << 1 + 1 << endl; // if we don't pass rf

Re: [Rcpp-devel] How to set a default value when call a R function in Rcpp

2016-11-10 Thread Dirk Eddelbuettel
On 11 November 2016 at 05:16, Jingyu He wrote: | I'm writing a R package by Rcpp and I have a problem when setting default value | when call a R function in Rcpp. Here is an example to pass a R function to C++, | provided by http://adv-r.had.co.nz/Rcpp.html | | #include | using namespace Rcpp;

[Rcpp-devel] How to set a default value when call a R function in Rcpp

2016-11-10 Thread Jingyu He
Hi, I'm writing a R package by Rcpp and I have a problem when setting default value when call a R function in Rcpp. Here is an example to pass a R function to C++, provided by http://adv-r.had.co.nz/Rcpp.html #include using namespace Rcpp;// [[Rcpp::export]]RObject callWithOne(Function f) { re