I am creating my own package in R. Within my package I am using the ggnet2
function from GGally
package. I am trying to get my package CRAN ready and Im using a bunch of tests from the devtools
package.
My issue is, I get an error when I run the following devtools
tests:
library(devtools)
check_win_release()
check_win_devel()
The error that is being thrown back is:
Error: please install the package 'network'. install.packages('network')
Backtrace:
x
1. \-myPackage::plotNetwork(vi) test_plots.R:34:2
2. +-base::suppressMessages(...)
3. | \-base::withCallingHandlers(...)
4. \-GGally::ggnet2(...)
5. \-GGally:::require_namespaces(c("network", "sna", "scales"))
Now, when I look up the source code for ggnet2
, the very 1st line of code is:
require_namespaces(c("network", "sna", "scales"))
In my NAMESPACE
file I have the ggnet2
function imported, along with ggplot2
, like so:
import(ggplot2)
importFrom(GGally,ggnet2)
And I also have GGally
and ggplot2
under the Imports field in my DESCRIPTION
file within my package.
I have tried adding network
and sna
to the suggests
field in my DESCRIPTION
file, but the error still remains (I am using the scales
package elsewhere within my package, so Im importing it separately).
This error is from a test file that I'm using with devtools::test()
but (on my machine I have these packages installed) I'm guessing that when I run check_win_release()
the machine that the tests are being preformed on don't have the required packages!?
I was wondering how do I solve this error? Or what are the best practices when importing a function that requires the namespace from other functions from other packages?