Next: matwrite() Up: MacAnova Help File Previous: matrices   Contents


matrix(x,Rowdim [,KeyPhrases]), x a vector, Rowdim > 0 an integer
  dividing length(x)
matrix(x [,KeyPhrases]), x a generalized matrix.
KeyPhrases can be labels:structure(rowLabs,colLabs), notes:Notes and
  silent:T, where rowLabs, colLabs and Notes are CHARACTER scalars or

Keywords: matrix algebra, variables, combining variables
matrix(x,Rowdim) creates a matrix (two dimensional array) with Rowdim
rows containing the data in x.  x can be a vector, matrix, or higher
dimensional array, all of whose elements are used, with first subscript
changing fastest, second subscript, if any, changing next, and so on.

Rowdim must be a positive integer exactly dividing the length of vector,
matrix, or array x.

  Cmd> c <- matrix(vector(1,1,1, -1,1,0, -1,-1,2),3)
creates the following matrix:
            1   -1   -1
       c  = 1    1   -1 .
            1    0    2

matrix(x), with no Rowdim, is equivalent to matrix(x,nrows(x)).  It is
valid for any one- or two-dimensional x, or for any higher dimensional
array with no more than two dimensions greater than 1, that is for any x
such that 'ismatrix(x)' would be True.  See topics ismatrix() and

Example: h <- matrix(SS[2,,]) creates a true p by p matrix from the 1 by
p by p array SS[2,,], if SS is an array of SSCP matrices created as a
side effect by manova().  See manova().

Although most operations, including matrix multiplication, matrix
inversion, and eigenvalue computation, treat SS[2,,] and matrix(SS[2,,])
identically, there are a few that do not.  Using matrix() can avoid some

On both usages, you can specify row and column labels for the output
using keywords labels.  See topic 'labels' for details.

You can attach a CHARACTER vector of descriptive notes to the result
using keyword phrase 'notes:Notes'.  See topic 'notes' for details.

When x is a matrix and either Rowdim is not specified or nrows(x) =
Rowdim, any coordinate labels or descriptive notes of x are transferred
to the result unless 'labels' or 'notes' provide new labels or notes or
are NULL.

See also topics array(), nrows(), 'matrices'.

Gary Oehlert 2003-01-15