powered by
Version of diag that has more consistent behavior
diagonal(x, len = NA, ...)
A vector, matrix or array with third mode length 1
numeric dimensions of new diagonal matrix to me made. Recycles values in x.
parameters passed to diag
if x is a vector or integer, return a matrix with x on the diagonal. If x is a matrix, or degenerate array, return the diagonal of x.
# NOT RUN { diagonal(c(1,3)) diagonal(matrix(1:6, 2,3)) diagonal(5) diagonal(c(5,2),3) diagonal(array(1:12, dim=c(3,4,1))) # }
Run the code above in your browser using DataLab