I have made my own package called "test" and I install it. However, there exist some problem.
For example, in my .R file, I use function "rowQuantiles" from other package called "matrixStats".
And I already add
import(matrixStats)
to namespace file
and add
Imports:matrixStats (>= 0.57.0)
to description file.
However, whenever I library my own pakcage
library(test)
The following error always comes out
could not find function "rowQuantiles"
How can I make that whenever I library my own package it will load other required packages. Just like the following
> library(ggpubr)
Loading required package: ggplot2
Key to understand this is to understand the difference between loading a package and attaching a package.
Packages listed under Imports:
are only loaded when your package attached, ie when you do library(mypkg)
. In contrast, packages listed under Depends:
are loaded and attached. So, if you use:
Depends: matrixStats
then all of matrixStats functions will be on the search()
path when you package is attached.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.