powered by
Extract or replace the diagonal of a matrix, or construct a diagonal matrix (replace diag function from R-base)
mydiag(x = 1, nrow, ncol)
a matrix, vector or 1D array, or missing.
Optional number of rows for the result when x is not a matrix.
Optional number of columns for the result when x is not a matrix.
If x is a matrix then diag(x) returns the diagonal of x. The resulting vector will have names if the matrix x has matching column and rownames.
diag
# NOT RUN { mydiag(1) mydiag(c(1,2)) # }
Run the code above in your browser using DataLab