问题
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