Skip to content

generate matrix of matrices

1 message · Felipe Zapata

#
A general question for R users about matrix manipulation:

I have two symmetric distance matrices (measuring distances in 2  
different variables) and I am trying to build a new matrix showing one  
half of one of the matrices (below diagonal) and the other half of  
other matrix (above he diagonal). Is there any R function to do this??  
any help would be appreciated.

This is what i am talking about

The matrices I have:

matrix 1:
	[1]	[2]	[3]
[1]	0	a	b
[2]	a	0	c
[3]	b	c	0

matrix 2
	[1]	[2]	[3]
[1]	0	x	y
[2]	x	0	z
[3]	y	z	0

The matrix I want
	[1]	[2]	[3]
[1]	0	a	b
[2]	x	0	c
[3]	y	z	0

Thanks,

FZ.