Do I need to import RccpEigen in the DESCRIPTION file for an R package using it, or is “LinkingTo” enough?

≡放荡痞女 提交于 2020-01-21 08:36:11

问题


I used the RcppEigen.package.skeleton() as a template for adding a small function to an existing R package, so that my DESCRIPTION file now has the lines:

Imports: Rcpp (>= 0.11.3), RcppEigen (>= 0.3.2.3.0)
LinkingTo: Rcpp, RcppEigen

However, doing R CMD check --as-cran <myPackageName_1.0.0>.tar.gz gives the following:

"Package in Depends/Imports which should probably only be in LinkingTo: 'RcppEigen'"

The Writing R Extensions page says: "Specifying a package in ‘LinkingTo’ suffices if these are C++ headers containing source code or static linking is done at installation: the packages do not need to be (and usually should not be) listed in the ‘Depends’ or ‘Imports’ fields. This includes CRAN packages BH and almost all users of RcppArmadillo and RcppEigen."

I don't know any C++, so I don't know what this means. My procedure for creating the package is here: RcppEigen - going from inline to a .cpp function in a package and "Map"

Is it okay to remove the RcppEigen from "Imports" and why/why not? (i.e. Can you please explain what the Writing R Extension page is saying, for my case, so that I can understand what I'm doing? Both the R and software experts in my lab said they don't understand the difference between "Imports" and "LinkingTo".)


回答1:


Briefly:

  1. There are currently 25 packages on CRAN which use RcppEigen. That makes 25 working case studies. You could look at one or two.
  2. LinkingTo: is generally enough.
  3. It may be a bug that the skeleton generator still adds Imports. We no longer do that in RcppArmadillo.

When I just ran the corresponding function for RcppArmadillo, I got

Imports: Rcpp (>= 0.11.3)
LinkingTo: Rcpp, RcppArmadillo

so I am leaning towards a bug. And I now opened an issue ticket for it.

More broadly, the differences between LinkingTo: and Imports: are

  • Imports: is the preferred, modern alternative to Depends; you also need to use NAMESPACE
  • LinkingTo: is chiefly used to point to header files as we do here.

So Writing R Extensions, or Hadley's online book for details.



来源:https://stackoverflow.com/questions/27789204/do-i-need-to-import-rccpeigen-in-the-description-file-for-an-r-package-using-it

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