gpt4 book ai didi

r - 由RcppArmadillo.package.skeleton创建的NAMESPACE选项导致错误

转载 作者:行者123 更新时间:2023-12-04 07:15:38 28 4
gpt4 key购买 nike

我正在创建一个包含Rcpp函数(取决于RcppArmadillo)的R包,因此我首先通过RcppArmadillo.package.skeleton生成包框架。但是,当我roxygenize我的包时,它给了我下面显示的错误。

R代码

library(roxygen2)
library(RcppArmadillo)
library(Rcpp)
RcppArmadillo.package.skeleton(name = "prac_181206", example_code = FALSE)
roxygenize(package.dir = "prac_181206", roclets = "rd")

错误
Error in getDLLRegisteredRoutines.DLLInfo(dll, addNames = FALSE) : 
must specify DLL via a “DLLInfo” object. See getLoadedDLLs()

花了一些时间后,我发现可以通过删除 .registration文件中的 NAMESPACE选项来解决此问题,如下所示。

原始NAMESPACE文件
useDynLib(prac_181206, .registration=TRUE)
importFrom(Rcpp, evalCpp)
exportPattern("^[[:alpha:]]+")

简而言之,将上面的第一行更改为 useDynLib(prac_181206)后,它可以正常工作,但是我不明白错误的含义以及为什么我的解决方案有效。

有人能帮我解决这个问题吗?我很感激!

因为这是一个玩具示例,希望可以重现,所以我在上面的 man创建的 srcRcppArmadillo.package.skeleton文件夹中未包含任何其他函数。

仅供引用,关于我的平台的相关信息是
  • Windows 7 x64
  • R-3.5.1,Rstudio-1.1.423
  • Rcpp-0.12.19,RcppArmadillo-0.9.100.5.0
  • roxygen2-6.1.1
  • 最佳答案

    也就是说,据我所知,roxygen2 issue ticket #771是我于8月3日提交的,但仍未解决。尽管roxygen2团队已将其关闭。请随时跟进。

    如果使用roxygen2 6.0.1,它将起作用:

    edd@rob:/tmp$ r -lRcppArmadillo -e'RcppArmadillo.package.skeleton(name = "prac_181206", example_code = FALSE)'

    Calling kitten 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 './prac_181206/Read-and-delete-me'.

    Adding pkgKitten overrides.
    Deleted 'Read-and-delete-me'.
    Done.

    Consider reading the documentation for all the packaging details.
    A good start is the 'Writing R Extensions' manual.

    And run 'R CMD check'. Run it frequently. And think of those kittens.


    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
    edd@rob:/tmp$ cd prac_181206/
    edd@rob:/tmp/prac_181206$ roxy.r
    ** Using cached version 6.0.1 of roxygen2.
    First time using roxygen2. Upgrading automatically...
    Updating roxygen version in /tmp/prac_181206/DESCRIPTION
    Loading required package: Rcpp
    edd@rob:/tmp/prac_181206$

    其中 roxy.rthis simple wrapper,是 roxygen2 6.0.1的硬连线。

    关于r - 由RcppArmadillo.package.skeleton创建的NAMESPACE选项导致错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53642735/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com