R/vec2mat.R

Defines functions vec2mat

Documented in vec2mat

vec2mat <-
function(x, type="adjMatrix"){
	nodes <- getNumNodes(x, type)
	
	if(tolower(type) == "adjmatrixlt" || tolower(type) == "lt"){
		y <- matrix(0, nodes, nodes)
		y[lower.tri(y)] <- x
		y <- y + t(y)
	}else if(tolower(type) == "diag" || tolower(type) == "d"){
		y <- matrix(0, nodes, nodes)
		diag(y) <- x
	}else{
		y <- matrix(x, nodes, nodes)
	}
	
	return(y)
}

Try the bingat package in your browser

Any scripts or data that you put into this service are public.

bingat documentation built on May 1, 2019, 9:11 p.m.