attempt to apply non-function when using roxygenise(), can't find source of error

痴心易碎 提交于 2019-12-13 03:24:25

问题


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 

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()

The output is the following:

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:


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

Session info:

> 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

Your commands:

> 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 

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.



来源:https://stackoverflow.com/questions/52065068/attempt-to-apply-non-function-when-using-roxygenise-cant-find-source-of-erro

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!