Trouble with importing specific functions from OpenMx into my package
I am currently developing an R package called nlpsem, and I am trying to use some functions from the OpenMx package. Specifically, I am trying to use the mxOption and imxReportProgress functions. However, I am encountering some issues when trying to use these functions without explicitly loading the OpenMx package with library(OpenMx).
In my DESCRIPTION file, I have the following lines:
Imports:
OpenMx, ggplot2, dplyr, tidyr, stringr, Matrix, nnet, readr, methods
And in my NAMESPACE file, I have the following lines:
importFrom(OpenMx,diag2vec)
importFrom(OpenMx,imxReportProgress)
importFrom(OpenMx,mxAlgebra)
importFrom(OpenMx,mxAlgebraFromString)
importFrom(OpenMx,mxBootstrap)
importFrom(OpenMx,mxCI)
importFrom(OpenMx,mxCompare)
importFrom(OpenMx,mxData)
importFrom(OpenMx,mxEval)
importFrom(OpenMx,mxEvalByName)
importFrom(OpenMx,mxExpectationMixture)
importFrom(OpenMx,mxFactorScores)
importFrom(OpenMx,mxFitFunctionAlgebra)
importFrom(OpenMx,mxFitFunctionML)
importFrom(OpenMx,mxMatrix)
importFrom(OpenMx,mxModel)
importFrom(OpenMx,mxOption)
importFrom(OpenMx,mxPath)
importFrom(OpenMx,mxRun)
importFrom(OpenMx,mxSE)
importFrom(OpenMx,mxTryHard)
importFrom(OpenMx,omxGetParameters)
Despite having these lines in my DESCRIPTION and NAMESPACE files, I still get the following error when trying to use the mxOption function without loading the OpenMx package:
Error in mxOption(model = NULL, key = "Default optimizer", "CSOLNP", reset = FALSE) :
could not find function "mxOption"
I have tried several approaches to resolve this issue, including checking the OpenMx version, checking the function documentation, explicitly loading the OpenMx package, using the double colon operator, checking for conflicts, and rebuilding and reloading my package. However, none of these steps have resolved the issue.
I would greatly appreciate any guidance or suggestions on how to properly import and use the mxOption and imxReportProgress functions from the OpenMx package in my nlpsem package.
Thank you for your time and assistance!
Best regards,
Veronica
Hi Veronica,
I suggest looking at either [umx](https://github.com/tbates/umx/blob/master/DESCRIPTION) or [EasyMx](https://bitbucket.org/mhunter/easymx/src/master/DESCRIPTION) approaches.
Hunter's approach in EasyMx seems the easiest, he just Depends: R (>= 3.0.0), OpenMx in the DESCRIPTION, then he
import(OpenMx)
in NAMESPACE.Our impression is that your code should also work, have you tried
OpenMx::mxOption(model = NULL, key = "Default optimizer", "CSOLNP", reset = FALSE)
though this is a bit cumbersome.Best,
Luis
Log in or register to post comments
In reply to Hi Veronica, by lf-araujo
Thanks Luis :) I set OpenMx
Best regards,
Veronica
Log in or register to post comments