ranges and subranges implemented in MxAlgebra expressions

1 reply [Last post]
mspiegel's picture
Offline
Joined: 07/31/2009

In the next binary release** you will be able to use ranges and subranges in MxAlgebra expression. The range operator "x : y" creates a column vector of elements [x, x+1, x+2, ..., y]. In addition, the square bracket operator now supports subranges. The following are now valid MxAlgebra expressions:

foo <- mxAlgebra(bar[1:2, 3:4], name = 'foo')
foo <- mxAlgebra(bar[1:2, 1], name = 'foo')
foo <- mxAlgebra(bar[1:2, ], name = 'foo')
foo <- mxAlgebra(bar[cbind(1,3,5), ], name = 'foo') # select odd rows
foo <- mxAlgebra(bar[cbind(1,1,1), ], name = 'foo') # select first row three times
foo <- mxAlgebra(bar[cbind('x', 'y', 'z'), ], name = 'foo') # use dimnames
foo <- mxAlgebra(bar[-1:-3, ], name = 'foo') # remove first, second, and third rows

The square bracket operator is quite versatile. We have 25 test cases in our test suite devoted to this operator. If we missed a case, and you figure out some way to break the operator, please let us know.

** OpenMx 0.2.6. Version 0.2.5 has been released without a news announcement.

Jeff's picture
Offline
Joined: 07/31/2009
Very nice! This is becoming

Very nice! This is becoming quite a powerful operator.