我使用Rcpp :: Rcpp.package.skeleton()生成Rcpp软件包,或者使用RStudio使用roxygen2文档进行测试,并将文件夹src中生成的测试cpp函数更改为:
#include <Rcpp.h>
using namespace Rcpp;
//’ Testing documentation with Rcpp
//’
//’ @param x Character vector for testing
//’ @param y Numeric vector for testing more
//’
//’ @return List of x and y
//’
//’ @export
// [[Rcpp::export]]
List rcpp_hello_world(CharacterVector x,NumericVector y) {
List z = List::create( x, y ) ;
return z ;
}
我从man删除了默认的.rd文件,并根据roxygen的要求将Encoding: UTF-8
添加到了Description文件中。
然后我在Rstudio上运行ctrl-shift-b(安装并重新启动)
==> Rcpp :: compileAttributes()
- 更新后的R / RcppExports.R
==> devtools :: document(roclets = c('rd','collate','namespace'))
更新testRcpp1文档首次使用roxygen2。升级中 自动...正在加载testRcpp1警告:现有的“名称空间” 文件不是roxygen2生成的,不会被覆盖。 文档完成
==> R CMD安装 ...
我检查了man文件夹,并且没有生成rd文件,找不到我做错的事情。
sessionInfo()是:
R version 3.5.1 (2018-07-02)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.5 LTS
Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.6.0
LAPACK: /usr/lib/lapack/liblapack.so.3.6.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=es_AR.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=es_AR.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=es_AR.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=es_AR.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] Rcpp_1.0.0 testRcpp1_1.0
loaded via a namespace (and not attached):
[1] crayon_1.3.4 withr_2.1.2 rprojroot_1.3-2 assertthat_0.2.0 R6_2.2.2 backports_1.1.2
[7] magrittr_1.5 cli_1.0.0 rlang_0.2.1 rstudioapi_0.8 testthat_2.0.1 desc_1.2.0
[13] tools_3.5.1 pkgload_1.0.2 yaml_2.1.19 compiler_3.5.1 sessioninfo_1.1.1
答案 0 :(得分:1)
问题似乎出在您用于评论的字符上。您当前的代码
//’ Testing documentation with Rcpp
//’
//’ @param x Character vector for testing
//’ @param y Numeric vector for testing more
使用’
(这是“右单引号”字符:代码146或0x92)而不是'
(这是“撇号”字符:代码39或0x27)。解析器不查找右撇号,而仅查找撇号。所以只需更改为
//' Testing documentation with Rcpp
//'
//' @param x Character vector for testing
//' @param y Numeric vector for testing more