TABLE OF CONTENTS
miscUtils/mdiag [ Functions ]
NAME
mdiag --- replacement for diag()
FUNCTION
works like diag(), except for length 1 vector inputs, in which case it returns a 1x1 matrix
SYNOPSIS
881 mdiag <- function(x)
INPUTS
x a vector or matrix
OUTPUTS
if x is a vector, a matrix with x as its diagonal if x is a matrix, a vector containing its diagonal
SOURCE
884 if(is.vector(x) && length(x) == 1 && x < 1) return(matrix(x, 1, 1)) else return(diag(x))