Hang's Blog
Observations and thinkings about economy, society and life.
Pages
Showing posts with label
symmetric matrix
.
Show all posts
Showing posts with label
symmetric matrix
.
Show all posts
Wednesday, 12 November 2014
Convert Matrix into Symmetric in R
require(Matrix):
forceSymmetric(dat, uplo="U"))
Assign the lower triangular part to the upper triangular part:
dat[upper.tri(dat)] <- t(dat)[lower.tri(dat)]
micEcon package:
symMatrix(dat[upper.tri(dat, TRUE)], nrow=nrow(dat), byrow=TRUE)
Older Posts
Home
Subscribe to:
Comments (Atom)