dmat(n,val), n > 0 integer, val a REAL, CHARACTER or LOGICAL scalar dmat(vec), vec a REAL, CHARACTER or LOGICAL vector. |

dmat(n,val), where n is a positive integer and val is a scalar (length(val) = 1), produces an n by n diagonal matrix with val down the diagonal. dmat(a) where a is a vector of length n, a n by 1 matrix, or a 1 by n matrix, produces a n by n diagonal matrix with the elements of a down the diagonal. Example: Cmd> iden5 <- dmat(5,1) # or dmat(rep(1,5)) produces a 5 by 5 identity matrix. See also diag().

Gary Oehlert 2003-01-15