Error in mxVersion() : subscript out of bounds (using R 2.12.0 and OpenMx 1.0.2)

Posted on
Picture of user. tbates Joined: 07/31/2009

Hi There,
Student had problem running a script today having updated to R version 2.12.0 (2010-10-15) in order to run OpenMx 1.0.2

Model (previously running fine) came back with error:
CP_fit1 = mxRun(CP_Model1)
Running fullCommon
Error in mxVersion() : subscript out of bounds

trying mxVersion itself, I now get
mxVersion()
Error in mxVersion() : subscript out of bounds

After quitting R, and restarting... error persists

> library(OpenMx)
Attaching package: 'OpenMx'
> mxVersion()
Error in mxVersion() : subscript out of bounds

Replied on Mon, 11/08/2010 - 14:45
Picture of user. mspiegel Joined: Jul 31, 2009

Did you try mxVersion() from a new R session? Your R session will do some funny things if you already have the library loaded and you try to install the new version.

Replied on Mon, 11/08/2010 - 15:18
Picture of user. tbates Joined: Jul 31, 2009

In reply to by mspiegel

yes, quit r, reloaded it, then started again. hence the comment "After quitting R, and restarting... error persists"

> library(OpenMx)
Attaching package: 'OpenMx'
> mxVersion()
Error in mxVersion() : subscript out of bounds

will try again tomorrow on the student's computer when she's in.
t

Replied on Mon, 11/08/2010 - 15:36
Picture of user. Ryne Joined: Jul 31, 2009

In reply to by tbates

The whole of mxVersion consists of two lines of code, copied-and-pasted here:


libMatrix <- installed.packages()
return(libMatrix["OpenMx", "Version"])

I'd guess that 'subscript out of bounds' means 'there's nothing called "OpenMx" in the list of installed packages.' As mxRun uses mxVersion to fill the mxVersion slot in the output. Now, I don't know what to do if OpenMx doesn't appear in the list of installed packages, but it at least tells us that's where the problem is. I don't think I've seen 'attaching OpenMx' as output from a library() call, but that could be system-specific or indicate a problem with the package load. Simple test: replace mxVersion with the following code and see if mxRun works (note: replacing OpenMx functions with your own work is very very very rarely a good idea).


mxVersion <- function(){
return("Spiegel hasn't slept since R 2.11")}

Replied on Mon, 11/08/2010 - 15:42
Picture of user. mspiegel Joined: Jul 31, 2009

In reply to by Ryne

Thanks. When I look at it, there's no reason that mxVersion() should fail hard. I forgot we include it at the end of mxRun(). I'll change it to return a NA if the library is not found.


libMatrix <- installed.packages()
if (!("OpenMx" %in% rownames(libMatrix))) return(NA)
return(libMatrix["OpenMx", "Version"])

Replied on Mon, 11/08/2010 - 18:14
Picture of user. tbates Joined: Jul 31, 2009

In reply to by Ryne

Hi Ryne... like the 2.11 optimism!

This seems to be a mac build * R version 2.12.0 interaction.

I just upgraded my home laptop to 2.12, installed the OpenMx ready-to-wear version and got
> mxVersion()
Error in mxVersion() : subscript out of bounds

Built my own version from svn...
mxVersion()
[1] "999.0.0-1448"

Replied on Tue, 11/09/2010 - 11:13
Picture of user. tbates Joined: Jul 31, 2009

In reply to by tbates

OK. Solved. Installed packages is for some reason detecting the wrong architecture. Turning that off works.
The off the rack version is installing for "i386", but my (and students) .Platform$r_arch = "x86_64"

I guess too that there are a range of optimisations to be had above i386 with the gcc compilers?

Perhaps it will be worth spending some time to build a compile pool to generate more versions without poor Mike S having to guide it all manually...? Not sure.

libMatrix <- installed.packages(subarch=NULL)
> libMatrix["OpenMx",]
Package LibPath Version
"OpenMx" "/Users/tim/Library/R/2.12/library" "1.0.2-1497"
Priority Depends Imports
NA "methods" NA
LinkingTo Suggests Enhances
NA "snowfall" NA
OS_type License Archs
NA "Apache License 2.0" "i386"
Built
"2.12.0"
>

Replied on Tue, 11/09/2010 - 11:18
Picture of user. mspiegel Joined: Jul 31, 2009

Ah, is this a windows machine? We have libnpsol successfully compiled for 32-bit windows but not 64-bit windows.

Replied on Tue, 11/09/2010 - 11:39
Picture of user. mspiegel Joined: Jul 31, 2009

In reply to by tbates

This is why we can't have nice things. Because R decides to add a new field to the package DESCRIPTION file and not put it in the documentation. OK, I just manually inserted the line into the package file. Can you have your student try installing OpenMx again using the web installer? Everything should just work.

Thanks for spotting this, sorry for doubting you earlier. That's the problem when I test on the same system I build.

Replied on Tue, 11/09/2010 - 11:48
Picture of user. tbates Joined: Jul 31, 2009

In reply to by mspiegel

jeez that f*in cat is scary! :-)

All working well now as far as i can see:

repos <- c('http://openmx.psyc.virginia.edu/packages/')
install.packages(pkgs=c('OpenMx'), repos=repos)

mxVersion()
[1] "1.0.2-1497 & smooth runnin's dr mike!"