Depends and Imports with OpenMx
Posted on

Forums
Hi everyone,
I am currently in the process of getting a new package on CRAN. My package uses openMx to estimate SE Models. Normally, to upload a package on CRAN, one would specify what packages are required. For example, I would put the following in my Description file:
Depends: OpenMx, MASS
Imports: OpenMx, MASS
if I had functions that use openmx and the MASS package. And in my Namespace file:
import("OpenMx", "MASS")
The problem is that R doesn't recognize OpenMx because it is not on R's repository. Does anyone know a way around this? Thanks in advance for the help.
OpenMx is still not 100% open source
To get on CRAN, we need an alternative to NPSOL. We are working on integrating CSOLNP, but this work is not done yet.
Log in or register to post comments
no problem?
I don't think there's a problem putting a package on CRAN which depends on packages that are not on CRAN. I'd use the devtools package to build and check (and release) the package: very good at doing these sanity checks (and for a nice development cycle, roxygen etc.)
I'd guess you'll just need to wrap the examples in don't run tags..
Add an INSTALL maybe to help people find OpenMx, and document the requirement and manual element in yourName-package.Rd
setwd("~/bin/yourpackage/");
devtools::check()
FYI, other stuff I use a bit (but have not yet pushed to cran with...) is
setwd("~/bin/umx/umx"); devtools::document(); devtools::install();
devtools::load_all()
devtools::dev_help("yourFun")
https://github.com/hadley/devtools
https://github.com/hadley/devtools/wiki/Philosophy
Log in or register to post comments
In reply to no problem? by tbates
require in functions
Thanks for the input. I commented out all the examples, and removed openmx from the namespace and dependencies, but the problem is that many of the functions have "require(OpenMx)." When I run CMD check on my computer, it flags that as problematic and gives me the following message:
* checking for unstated dependencies in R code . . . WARNING 'library' or 'require' call not declared from: 'OpenMx'
Any ideas?
Log in or register to post comments
In reply to require in functions by fife
Warning or Error?
Is it a warning or an error? The difference being that a warning indicates that something might not be right but it will let you do it anyway, whereas an error stops anything from being done. If it's just a warning, then I think you're all set.
Log in or register to post comments
In reply to Warning or Error? by mhunter
require() should return FALSE and give a warning
require() should return FALSE and give a warning if the package isn't found.
You can use a snippet like:
hasOpenMx <- suppressWarnings(require("OpenMx"))
if(!hasOpenMx) {
stop(paste("This package uses OpenMx, but you do not currently have it installed. ",
"You can get it by visiting [http://openmx.psyc.virginia.edu/installing-openmx] and",
"following the instructions there.")
}
Or whatever you'd like to happen in the case that OpenMx doesn't load. The require() command above won't say anything if it fails. If you don't want it to say anything on success either, you can wrap the suppressWarnings() in a suppressMessages() as well.
Log in or register to post comments
In reply to require() should return FALSE and give a warning by tbrick
submit and see
It will be interesting to see how this works out: I'd have thought the issue that the cran algorithm has is that it wants to know what happens when OpenMx IS available: so just exiting all the functions prematurely won't pass the checks? But perhaps it does.
There must be a way, because semTools suggests OpenMx and is up on cran
https://github.com/simsem/semTools/wiki
I'd love to hear how this works out
Log in or register to post comments
In reply to require in functions by fife
How are you using require()?
If you get a Warning then I do not think CRAN will accept the package. I wonder though are you just calling require() or have you wrapped it in an if statement and issue an error if it returns FALSE? Does it make a difference?
Another avenue might be to see how packages on CRAN which augment OpenMx like semtools handle the issue.
Log in or register to post comments