Hang's Blog
Observations and thinkings about economy, society and life.
Pages
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)
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment