more flexible dimnames assignment: one vector, and rownames and colnames parameters

tbates's picture
Category:feature request

We quite often read and type things like

mxObject(…, dimnames = list(NULL, c("a", "b","c")))
# and
mxExpectationNormal(dimnames = list(c("a", "b","c"), c("a", "b","c")))

Add rownames and colnames parameters to allow:

mxObject(..., colnames = c("a", "b", 'c'))

in place of the harder to read

mxObject(…, dimnames = list(NULL, c("a", "b")))

Would be handy also to interpret a single vector input to dimnames as a list with both entries the same, i.e.:

mxObject(..., dimnames = c('a','b', 'c') )
# would function like:
mxObject(..., dimnames = list(c("a", "b", 'c'), c("a", "b", 'c')))

Best, t


mhunter's picture


Assigned to:Anonymous» tbates

I am not opposed to this. Have at it, Tim! The way to do it would be to copy the methods for dimnames used by the MxObject in question. For example, Line 276 of trunk/R/MxMatrix.R gives the setMethod("dimnames", ...) for MxMatrix objects. Create setMethod's and setReplaceMethod's for rownames and colnames that access and set the dimnames of the object. The dimnames are the "real" thing that the object has; rownames and colnames will then be wrappers for dimnames.