You are here

Depends and Imports with OpenMx

8 posts / 0 new
Last post
fife's picture
Joined: 07/01/2010 - 03:02
Depends and Imports with OpenMx

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.

jpritikin's picture
Joined: 05/24/2012 - 00:35
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.

tbates's picture
Joined: 07/31/2009 - 14:25
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


FYI, other stuff I use a bit (but have not yet pushed to cran with...) is

setwd("~/bin/umx/umx"); devtools::document(); devtools::install(); 

fife's picture
Joined: 07/01/2010 - 03:02
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?

mhunter's picture
Joined: 07/31/2009 - 15:26
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.

tbrick's picture
Joined: 07/31/2009 - 15:10
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 [] 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.

tbates's picture
Joined: 07/31/2009 - 14:25
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

I'd love to hear how this works out

mdewey's picture
Joined: 01/21/2011 - 13:24
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.