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

2016-11-11 Thread Jingyu He
It works, thanks a lot! Qiang Kou 于2016年11月11日 周五09:07写道: > Hi, Jingyu, > > I post a small example below. I think this is what you want. > > Best, > > KK > > #include > > using namespace Rcpp; > > //[[Rcpp::export]] > void test(Nullable f = R_NilValue) { > if (f.isNotNull()) { > Rcpp::Rcout

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

2016-11-11 Thread Qiang Kou
Hi, Jingyu, I post a small example below. I think this is what you want. Best, KK #include using namespace Rcpp; //[[Rcpp::export]] void test(Nullable f = R_NilValue) { if (f.isNotNull()) { Rcpp::Rcout << "Not NULL fun" << std::endl; Function f2(f); f2(); } else { Rcout <

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

2016-11-11 Thread Dirk Eddelbuettel
On 11 November 2016 at 05:53, Jingyu He wrote: | 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