R/ReadSymMatrixFromTriangle.R

`ReadSymMatrixFromTriangle` <-
function(file, n.vars){

	cov.vec <- c(scan(file))

	temp <- matrix(0,n.vars,n.vars)
		
	temp[upper.tri(temp,diag=TRUE)] <- cov.vec  # Yes, upper!

	diagonal <- diag(temp)

	resulting.matrix <- temp + t(temp)
	
	diag(resulting.matrix) <- diagonal

	resulting.matrix

} # closes the function

Try the SEMModComp package in your browser

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

SEMModComp documentation built on May 2, 2019, 6:37 a.m.