Skip to content
Prev 36157 / 63424 Next

for help on building a R package with several R function and a bunch of c, c++

Hello,
On 03/08/2010 06:16 PM, alex46015 at yahoo.com wrote:
I'd encourage you to use the .Call interface,
no

what I need do for  rcpp_hello_world.cpp rcpp_hello_world.cpp? it is 
template file handled by the program or it is for me to edit it as template?

those are examples that we expand to show the kind of code you can 
write. feel free to dump them.

In particular, it shows you how you declare c++ functions to be used by R:
- The RcppExport prevents c++ mangling. see the rationale for this in 
writing R extensions. (RcppExport is just an alias for extern "C")
- The function returns a SEXP (see writing R extensions)
- The function takes zero or more SEXP as input (see writing R extensions)

So I'd suggest you write your function something like this :

RcppExport SEXP tranptest( SEXP filename_, SEXP para_){
	Rcpp::CharacterVector filename( filename_ ) ;
	Rcpp::NumericVector para(para_) ;

	// use filename and para to do whatever you want to do with them
	// return  something
}
Again, I suggest you look into the .Call interface and go for something 
like this:

.Call( "tranptest", filenames, params, PACKAGE = "yourpackage" )
Rcpp.package.skeleton adds a useDynLib directive to the NAMESPACE so you 
should be fine.
>

  
    

Thread (14 messages)

alex46015 at yahoo.com for help on building a R package with several R function and a bunch of c, c++ Mar 5 Dirk Eddelbuettel for help on building a R package with several R function and a bunch of c, c++ Mar 5 alex46015 at yahoo.com for help on building a R package with several R function and a bunch of c, c++ Mar 5 Romain Francois for help on building a R package with several R function and a bunch of c, c++ Mar 7 alex46015 at yahoo.com for help on building a R package with several R function and a bunch of c, c++ Mar 7 Romain Francois for help on building a R package with several R function and a bunch of c, c++ Mar 7 alex46015 at yahoo.com for help on building a R package with several R function and a bunch of c, c++ Mar 8 Romain Francois for help on building a R package with several R function and a bunch of c, c++ Mar 8 Dirk Eddelbuettel for help on building a R package with several R function and a bunch of c, c++ Mar 8 Simon Urbanek for help on building a R package with several R function and a bunch of c, c++ Mar 8 Simon Urbanek for help on building a R package with several R function and a bunch of c, c++ Mar 8 alex46015 at yahoo.com for help on building a R package with several R function and a bunch of c, c++ Mar 8 Simon Urbanek for help on building a R package with several R function and a bunch of c, c++ Mar 8 alex46015 at yahoo.com for help on building a R package with several R function and a bunch of c, c++ Mar 8