krlmlr
krlmlr

Reputation: 25454

Renaming exported function using Rcpp::export fails on a specific installation

Exporting an Rcpp function with a different name succeeds on one machine but fails on the other. The R environments are very similar. What am I doing wrong?

Details

I have an R package with an Rcpp function that is exported with the following signature (in sample_int_crank.cpp):

// [[Rcpp::export(sample.int.crank)]]
IntegerVector sample_int_crank(int n, int size, NumericVector prob) {
    ...

This function is declared empty in a corresponding R file (sample_int_crank.R):

sample.int.crank <- function(n, size, prob) {
}

EDIT: When I remove this R file, the function is available. But where do I place roxygen2 comments for this function?

Now, when I install the package from GitHub,

library(devtools)
install_github('wrswoR', 'muelleki', '0.0.6')

on machine A it says:

> sample.int.crank
internal C++ function <0x29ddc40>
    signature : Rcpp::IntegerVector sample.int.crank(int, int, Rcpp::NumericVector)

and on machine B:

> sample.int.crank
function(n, size, prob) {
}
<environment: namespace:wrswoR>

EDIT: If sample_int_crank.R is removed from the package, the output looks different, but identical on A and B. What is going on here?

library(devtools)
install_github('wrswoR', 'muelleki')

> sample.int.crank
function (n, size, prob) 
{
    .Call("wrswoR_sample_int_crank", PACKAGE = "wrswoR", n, size, 
        prob)
}
<environment: namespace:wrswoR>

The sessionInfo() seems to be more or less identical, at least for R and Rcpp -- A:

> sessionInfo()
R version 2.15.3 (2013-03-01)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=C                 LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] wrswoR_0.0.6    logging_0.7-102 Rcpp_0.10.3     devtools_0.8   

loaded via a namespace (and not attached):
 [1] digest_0.5.2    evaluate_0.4.2  httr_0.1.1      memoise_0.1    
 [5] parallel_2.15.3 plyr_1.7.1.99.2 RCurl_1.95-0    stringr_0.6.1  
 [9] tools_2.15.3    whisker_0.1    

B:

> sessionInfo()
R version 2.15.3 (2013-03-01)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.utf-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.utf-8        LC_COLLATE=en_US.utf-8
 [5] LC_MONETARY=en_US.utf-8    LC_MESSAGES=en_US.utf-8
 [7] LC_PAPER=C                 LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.utf-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] wrswoR_0.0.6   logging_0.6-92 Rcpp_0.10.3    devtools_1.1

loaded via a namespace (and not attached):
[1] digest_0.6.3    evaluate_0.4.3  httr_0.2        memoise_0.1
[5] parallel_2.15.3 RCurl_1.95-4.1  stringr_0.6.2   tools_2.15.3
[9] whisker_0.1

Any idea?

Upvotes: 2

Views: 412

Answers (1)

Dirk is no longer here
Dirk is no longer here

Reputation: 368261

Concerning your question

But where do I place roxygen2 comments for this function?

I have to disappoint you that here simply is no support for roxygen(2) in Rcpp Attributes. Maybe you want to contribute that?

On the other hand, writing normal C++ functions in src/ and calling them from normal R functions is of course supported, and can be used by roxygen2 just fine.

As to what devtools does to your package: Also no idea. Neither Romain nor myself uses devtools, so you are in undocumented and undefined territory.

Upvotes: 1

Related Questions