diag(A), A a matrix. |

diag(a) creates a vector consisting of the diagonal elements a[1,1], a[2,2], ... of matrix a, which does not need to be square. The length of the result is min(nrows(a),ncols(a)). Matrix a may be REAL (most common), LOGICAL or CHARACTER. diag(a) is defined for an array with more than 2 dimensions, as long as there are only two dimensions with size > 1, interpreted as the number of rows and columns. For example, after manova(model) command, diag(SS[3,,]) is the diagonal of the sums of squares and cross-products matrix associated with term 3 in the model. See also dmat(), trace(), 'matrices'.

Gary Oehlert 2003-01-15