foo[x,y] for MxMatrix objects

No replies
mspiegel's picture
Offline
Joined: 07/31/2009

It was suggested at last week's developers meeting that it could be useful to use the extract operator for MxMatrix objects. So I've implemented foo[x,y] and foo[x,y] <- z where 'foo' is a MxMatrix object. The new feature has been checked into the subversion repository.

Some notes about foo[x,y]

  • returns a MxMatrix object
  • applies [x,y] extraction to the components of foo (values, labels, free, lbound, ubound)
  • returns a MxMatrix of the same type as foo, unless that would cause an error. In cases of errors, return a Full matrix.
  • returns a MxMatrix with the same 'name' as foo. Use foo[x,y,name='bar'] to change the name of the return value.

Some notes about foo[x,y] <- z

  • z must be a MxMatrix object.
  • applies [x,y] replacement to the components of foo using the components of z
  • any dimnames of the right-hand side (z) are dropped. This is how R behaves on regular matrix objects
  • ignores the name of the right-hand side (z)