[Rcpp-devel] Question about variadic argument "..." in Rcpp

Dirk Eddelbuettel edd at debian.org
Wed Jul 18 13:39:37 CEST 2012


On 18 July 2012 at 10:29, SHEN Fei wrote:
| Dear all,
| 
| I got some problems with the variadic argument "..." in Rcpp.
| 
| Suppose i have a R function f:
| f <- function(x,...)
| {
|     blabla
| }
| 
| In another R function, i want to pass this f as an argument to a C++ function,
| along with all its own parameters, i.e. x and the "...".

There is no C++ version of '...', so you can't (even though C/C++ have
"varags" but that is different). I think you may have to reconsider your approach.
 
| I found a method that applies  Rcpp Module to treat the various argument ...
| as _["..."]. But i'm still very confused. Would you please give me an example
| to show how to use Rcpp to do the function transformation, especially when the
| "..." argument is used.
| 
| And since the background of my program is a little special, i will also call R
| functions in the C++ function that i pass f to.
| 
| I knew that i can use Rcpp to call C++ functions in R, and use RInside to call
| R functions in C++. But can i use them both at the same time?

RInside can be used when you have a differnt main() function from another
program, and you want to add an R interpreter via embedding.

Rcpp is used to extend R, ie when you have a normal interactive (or scripted)
R session.  You do not use RInside in that case.

Dirk

| I've tried "R -> C++ -> R" with only Rcpp and that worked. But can i use Rcpp
| at "R -> C++" stage and use RInside at "C++ -> R" stage in one program? I'm
| still very confuse with the packages usage. Btw, i use Rcpp.package.skeleton()
| to create my package and i add RInside in the DESCRIPTION file, but it seems to
| be useless.
| 
| I'll very appreciate if you could give me another example to show how to pass
| "..." argument to a R function in the C++ environment.
| 
| Thank you very much!
| 
| --
| SHEN Fei
| 
| ----------------------------------------------------------------------
| _______________________________________________
| Rcpp-devel mailing list
| Rcpp-devel at lists.r-forge.r-project.org
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com  


More information about the Rcpp-devel mailing list