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