尝试在使用roxygenise()时应用非功能,找不到错误源

时间:2018-08-28 19:33:12

标签: rcpp roxygen

我正在尝试使用roxygen2将添加文档添加到我的任意Rcpp软件包中,并且不断收到相同的错误消息

> roxygen2::roxygenise("anRpackage")
First time using roxygen2. Upgrading automatically...
Error in .f(.x[[i]], ...) : attempt to apply non-function
In addition: Warning message:
roxygen2 requires Encoding: UTF-8 

我的源代码中的任何地方都没有“ .f(.x [[i]])”,并且我无法识别“ .f”的形式。这是某种隐藏功能吗?我应该如何调试此错误?我对编写R包很陌生,也许我错过了一些东西。...在此先感谢!

library(Rcpp)
library(RcppArmadillo)
library(roxygen2)
sessionInfo()

输出如下:

R version 3.4.2 (2017-09-28)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

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

other attached packages:
[1] roxygen2_6.1.0            RcppArmadillo_0.9.100.5.0 Rcpp_0.12.18             

loaded via a namespace (and not attached):
[1] compiler_3.4.2 R6_2.2.2       magrittr_1.5   tools_3.4.2    yaml_2.1.14   
[6] xml2_1.1.1     stringi_1.1.6  stringr_1.2.0  commonmark_1.4

1 个答案:

答案 0 :(得分:2)

这不是答案,但我想记录一下我在重现该问题上的失败尝试。由于我使用的是R的最新版本,并且没有可用的Windows环境,因此我将Docker容器与R版本一起使用。预言

$ docker run --rm -it rocker/r-ver:3.4.2 bash
# apt-get update
# apt-get install libxml2-dev
# install2.r -r https://cloud.r-project.org/ RcppArmadillo roxygen2

会话信息:

> library(Rcpp)
> library(RcppArmadillo)
> library(roxygen2)
> sessionInfo()
R version 3.4.2 (2017-09-28)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 9 (stretch)

Matrix products: default
BLAS: /usr/lib/openblas-base/libblas.so.3
LAPACK: /usr/lib/libopenblasp-r0.2.19.so

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=C             
 [7] LC_PAPER=en_US.UTF-8       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] roxygen2_6.1.0            RcppArmadillo_0.9.100.5.0
[3] Rcpp_0.12.18             

loaded via a namespace (and not attached):
[1] compiler_3.4.2 R6_2.2.2       magrittr_1.5   tools_3.4.2    xml2_1.2.0    
[6] stringi_1.1.6  stringr_1.2.0  commonmark_1.5

您的命令:

> RcppArmadillo.package.skeleton("anRpackage"); compileAttributes("anRpackage");roxygen2::roxygenise("anRpackage") 

Calling package.skeleton to create basic package.
Creating directories ...
Creating DESCRIPTION ...
Creating NAMESPACE ...
Creating Read-and-delete-me ...
Saving functions and data ...
Making help files ...
Done.
Further steps are described in './anRpackage/Read-and-delete-me'.

Adding RcppArmadillo settings
 >> added Imports: Rcpp
 >> added LinkingTo: Rcpp, RcppArmadillo
 >> added useDynLib and importFrom directives to NAMESPACE
 >> added Makevars file with Rcpp settings
 >> added Makevars.win file with RcppArmadillo settings
 >> added example src file using armadillo classes
 >> added example Rd file for using armadillo classes
 >> invoked Rcpp::compileAttributes to create wrappers
First time using roxygen2. Upgrading automatically...
Updating roxygen version in /anRpackage/DESCRIPTION
Loading anRpackage
Re-compiling anRpackage
Running /usr/local/lib/R/bin/R CMD INSTALL /anRpackage \
  '--library=/tmp/RtmpbM1VEb/devtools_install_7e040f6ccc8' --no-R --no-data \
  --no-help --no-demo --no-inst --no-docs --no-exec --no-multiarch \
  --no-test-load --preclean
* installing *source* package ‘anRpackage’ ...
** libs
g++ -std=gnu++11 -I/usr/local/lib/R/include -DNDEBUG  -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/RcppArmadillo/include" -I/usr/local/include  -fopenmp  -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -UNDEBUG -Wall -pedantic -g -Og -fdiagnostics-color=always -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++11 -I/usr/local/lib/R/include -DNDEBUG  -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/RcppArmadillo/include" -I/usr/local/include  -fopenmp  -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -UNDEBUG -Wall -pedantic -g -Og -fdiagnostics-color=always -c rcpparma_hello_world.cpp -o rcpparma_hello_world.o
g++ -std=gnu++11 -shared -L/usr/local/lib/R/lib -L/usr/local/lib -o anRpackage.so RcppExports.o rcpparma_hello_world.o -fopenmp -L/usr/local/lib/R/lib -lRlapack -lblas -lgfortran -lm -lquadmath -L/usr/local/lib/R/lib -lR
installing to /tmp/RtmpbM1VEb/devtools_install_7e040f6ccc8/anRpackage/libs
* DONE (anRpackage)
Warning: The existing 'NAMESPACE' file was not generated by roxygen2, and will not be overwritten.
Warning message:
roxygen2 requires Encoding: UTF-8 

我看到的唯一区别是操作系统和一些未连接的软件包,这些软件包在我的Docker容器中稍有更新。没有什么可以解释您这一方面的失败。

相关问题