[Rcpp-devel] How to put the code 2013-01-05-r-function-from-c++.cpp in the src/ directory of a package?

Peng Yu pengyu.ut at gmail.com
Mon May 27 05:12:05 CEST 2013


On Sun, May 26, 2013 at 6:00 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
>
> On 26 May 2013 at 17:39, Peng Yu wrote:
> | The straight forward answer to my question in the title is that
> | 2013-01-05-r-function-from-c++.cpp should not be directly put to src/
> | direction in an R package.
>
> Sorry but that is once again incorrect. Read the "Rcpp attributes" vignette,

I'd rather not to put it as incorrect or correction. I did not know
"compileAttributes".

> and learn about compileAttributes().  It does the wrapping of the posted
> function for you, and it does it right.  It provides the passage from a
> single function (or several functions) you can test via sourceCpp() to a
> package.

> Of course, one could also manually rewrite it for use in a package (and do
> what we did before Rcpp attributes). I would even call that easy (as your
> function is simple). But your attempts at that were rather wrong, though, as
> you mixed pieces from different approaches seemingly at random.
>
> All this is really fairly basic.  Take a day off, then read the docs, start
> from an even simpler example and work your way up from there.  Passing an R
> function from R to a C++ routine that is called from R is not difficult, but
> you have been managing to get lost for a few days now.

I have downloaded all the 108 packages that depend on Rcpp. The
following shows all the 5 packages that uses compileAttributes. These
are a very small fraction of all the packages that depend on Rcpp.
This fact suggests that compileAttributes is not commonly used and the
additional complexity required to use it may not justify the benefits
it brings.

~/Documents/src/R/cran/Rcpp_reverse_depends$ ackall compileAttributes
'ack' -v -g '/backup.*/|^backup.*/'  | 'ack' --color -x ''
'compileAttributes' | tab2space -t8
ALKr_0.5.3/R/RcppExports.R
1:# This file was generated by Rcpp::compileAttributes

ALKr_0.5.3/src/RcppExports.cpp
1:// This file was generated by Rcpp::compileAttributes

Delaporte_0.1-2/R/RcppExports.R
1:# This file was generated by Rcpp::compileAttributes

Delaporte_0.1-2/src/RcppExports.cpp
1:// This file was generated by Rcpp::compileAttributes

httpuv_1.0.5/R/RcppExports.R
1:# This file was generated by Rcpp::compileAttributes

httpuv_1.0.5/src/RcppExports.cpp
1:// This file was generated by Rcpp::compileAttributes

Kmisc_0.4.0-1/R/RcppExports.R
1:# This file was generated by Rcpp::compileAttributes

Kmisc_0.4.0-1/src/RcppExports.cpp
1:// This file was generated by Rcpp::compileAttributes

RcppRoll_0.1.0/R/RcppExports.R
1:# This file was generated by Rcpp::compileAttributes

RcppRoll_0.1.0/src/RcppExports.cpp
1:// This file was generated by Rcpp::compileAttributes--
Regards,
Peng


More information about the Rcpp-devel mailing list