问题描述
我正在尝试使用 roxygen2 将文档添加到我的任意 Rcpp 包中,但我不断收到相同的错误消息
I'm trying to use add documentation to my arbitrary Rcpp package using roxygen2, and I keep getting the same error message
> 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 包还很陌生,也许我遗漏了一些东西......提前致谢!
I do not have ".f(.x[[i]])" anywhere in my source code, and I don't recognize the form ".f". Is this some kind of hidden function? How should I debug this error? I'm quite new to writing R packages, perhaps I'm missing something.... Thanks in advance!
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
推荐答案
这不是答案,但我想记录我在重现问题时失败的尝试.由于我使用的是更新版本的 R 并且没有可用的 Windows 环境,因此我使用的是 R 版本的 docker 容器.准备工作
This is not an answer but I want to record my failed attempt at reproducing the issue. Since I am using a more current version of R and have no windows environment available, I am using a docker container with your R version. Preperations
$ 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 容器中略新.没有什么可以解释你这边的失败.
The only differences I am seeing are the OS and some not attached packages that are slightly newer in my docker container. Nothing that would explain the failure on your side.
这篇关于尝试在使用 roxygenise() 时应用非函数,找不到错误源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!