Make third party library available in my R package [duplicate]

纵饮孤独 提交于 2019-12-02 19:32:45

问题


I am developing an R package that uses third party functions available in the Bioconductor package "methyilumi"

In the code for my R package at the very beginning I import methylumi with library(methylumi).

During the development (I use roxygen2 and devtools) everything works fine. However, when I install the package and run my functions, I get the error: could not find function "methylumIDAT".

Of course everything is solved if I import the package manually, but how can I make so that methylumi is available whenever I load my own package?


回答1:


Since you are using devtools, you can add

devtools::use_package("methyilumi")

in the console, and call methyilumi::methylumIDAT in the body of your function. That way, the package is automatically listed in Imports in the DESCRIPTION file.

This sections gives the instructions for several different cases: http://r-pkgs.had.co.nz/namespace.html#imports




回答2:


This is done with the NAMESPACE file and also noted in the DESCRIPTION file. There are a few ways to import a function in NAMESPACE, but the simplest is just importFrom("[PACKAGE_NAME]",[FUNCTION_NAME). Then, in DESCRIPTION, add the package name to imports.

See this very good tutorial from Friedrich Leisch.

http://cran.r-project.org/doc/contrib/Leisch-CreatingPackages.pdf



来源:https://stackoverflow.com/questions/21986661/make-third-party-library-available-in-my-r-package

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