函数不可用于 .Call 使用 Rcpp.package.skeleton() 和 compileAttributes [英] Function not available for .Call using Rcpp.package.skeleton() and compileAttributes

查看:59
本文介绍了函数不可用于 .Call 使用 Rcpp.package.skeleton() 和 compileAttributes的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图密切关注 Rcpp 包文档,但我收到错误

.Call("MicroCreditLRVBR_TestJacobian", PACKAGE = "MicroCreditLRVBR") 中的错误:MicroCreditLRVBR_TestJacobian"不适用于 .Call() 包MicroCreditLRVBR"

包框架是用Rcpp.package.skeleton() 构建的.我复制了我的 RC++ 代码,修改了 Makevars 以指向包外的一些代码,更新了 DESCRIPTION 链接到 RcppEigen,并运行 compileAttributes().然后我运行 R CMD build 来创建一个 .gz 文件和 R CMD INSTALL 来安装它.它构建和链接成功,但因上述错误而终止.

我可以看到MicroCreditLRVBR_TestJacobian 函数确实在RcppExports.cppRcppExports.R 中定义.我不知道为什么它不适用于 .Call.

注意NAMESPACE包括useDynLib(MicroCreditLRVBR)exportPattern("^[[:alpha:]]+").>

当前状态的包的公共副本位于这个 github 存储库.任何帮助将不胜感激.

解决方案

当您切换名称时:

MicroCreditLRVB

MicroCreditLRVBR

您忘记修改NAMESPACE中的包名> 文件

例如

useDynLib(MicroCreditLRVB)

前往:

useDynLib(MicroCreditLRVBR)

另外,从 中删除第 1-22 行R.它们应该放在 /inst 中的演示"文件中.

最后,使用 BH 导入 boost 头文件,并减少 Makevars 中的绝对路径.

I am trying to follow closely the directions in the Rcpp package documentation, but I am getting the error

Error in .Call("MicroCreditLRVBR_TestJacobian", PACKAGE = "MicroCreditLRVBR") : 
  "MicroCreditLRVBR_TestJacobian" not available for .Call() for package "MicroCreditLRVBR"

The package framework was built with Rcpp.package.skeleton(). I copied in my R and C++ code, modified the Makevars to point to some code outside the package, updated the DESCRIPTION to link to RcppEigen, and ran compileAttributes(). I then ran R CMD build to create a .gz file and R CMD INSTALL to install it. It built and linked successfully, but terminated with the above error.

I can see that the function MicroCreditLRVBR_TestJacobian is indeed defined in RcppExports.cpp and RcppExports.R. I don't know why it is not available for .Call.

Note that NAMESPACE includes useDynLib(MicroCreditLRVBR) and exportPattern("^[[:alpha:]]+").

A public copy of the package in its current state is in this github repo. Any help would be appreciated.

解决方案

When you switched the name from:

MicroCreditLRVB

to

MicroCreditLRVBR

You forgot to modify the package name in the NAMESPACE file

e.g.

useDynLib(MicroCreditLRVB) 

goes to:

useDynLib(MicroCreditLRVBR) 

Also, remove lines 1-22 from microcredit_stan_lib.R. They should be put into a "demo" file found within the /inst.

Lastly, import boost headers using the BH and cut down on the absolute paths within the Makevars.

这篇关于函数不可用于 .Call 使用 Rcpp.package.skeleton() 和 compileAttributes的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆