Thanks Jorge, you answered my generic R question!

Cheers,

Felipe


On Feb 21, 2010, at 1:21 AM, Jorge Ivan Velez wrote:

> Hi Felipe,
>
> Try this:
>
> m1 <- matrix(c(0, 1, 2,
>                1, 0, 3,
>                2, 3, 0), 3,3)
> m1
>
> m2 <- matrix(c(0, 4, 5,
> 	       4, 0, 6,
> 	       5, 6, 0), 3,3)
> m2	
> 	
> m3 <- matrix(0, 3, 3)
> m3[lower.tri(m3)] <- m1[lower.tri(m1)]
> m3[t(lower.tri(m3))] <- m2[t(lower.tri(m1))]
> m3
>
> HTH,
> Jorge
>
> On Sun, Feb 21, 2010 at 2:02 AM, Felipe Zapata <> wrote:
> 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.
>
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac@stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>


	[[alternative HTML version deleted]]

