导出具有不同名称的 Rcpp 函数在一台机器上成功,但在另一台机器上失败。R 环境非常相似。我究竟做错了什么?
细节
我有一个带有 Rcpp 函数的 R 包,它使用以下签名 (in sample_int_crank.cpp
) 导出:
// [[Rcpp::export(sample.int.crank)]]
IntegerVector sample_int_crank(int n, int size, NumericVector prob) {
...
此函数在相应的 R 文件 ( sample_int_crank.R
) 中声明为空:
sample.int.crank <- function(n, size, prob) {
}
编辑:当我删除这个 R 文件时,该功能可用。但是我在哪里为这个函数放置 roxygen2 注释呢?
现在,当我从 GitHub 安装包时,
library(devtools)
install_github('wrswoR', 'muelleki', '0.0.6')
在机器A上它说:
> sample.int.crank
internal C++ function <0x29ddc40>
signature : Rcpp::IntegerVector sample.int.crank(int, int, Rcpp::NumericVector)
在机器B上:
> sample.int.crank
function(n, size, prob) {
}
<environment: namespace:wrswoR>
编辑:如果sample_int_crank.R
从包中删除,输出看起来不同,但在A和B上相同。这里发生了什么?
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>
sessionInfo()
似乎或多或少相同,至少对于 R 和 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
乙:
> 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
任何的想法?