# [R] problem with lower, upper triangles and diagonal

Birgit Lemcke birgit.lemcke at systbot.uzh.ch
Tue Oct 9 17:41:53 CEST 2007

```Hello Fernando,

I have two problems with you suggestion:

First what I get back if I use lowerTriangle is this:

(f2.low<-lowerTriangle(f2, diag = TRUE))
[1] 0 1 1 1 1 0 1 0 0 1 1 1 1 1 0

But I need a triangle and I need an object of class dist to use
afterwards the mantel.rtest function.

So I think I need a possibility in as.dist to get the upper and lower
triangle with the original diagonal values.

Regards

Birgit

Am 09.10.2007 um 16:41 schrieb F.Tusell:

> Birgit,
>
> Seems to me that
>
>         upperTriangle
>         lowerTriangle
>
> in package gdata may be an answer to you problems. Best, ft.
> --
> Fernando TUSELL                                e-mail:
> Departamento de Econometría y Estadística       fernando.tusell at ehu.es
> Facultad de CC.EE. y Empresariales
> Universidad del País Vasco                     Tel:   (+34)94.601.3733
> Avenida Lendakari Aguirre, 83                  Secr:  (+34)94.601.3740
> E-48015 BILBAO                                 Fax:   (+34)94.601.3754
> (Spain)                              http://www.et.bs.ehu.es/~etptupaf
> ----------------------------------------------------------------------
>
>
>
>

Birgit wrote:

Hello R user!

I have again a problem and sometimes I have the feeling that I will
never learn to solve my problems by myself.
But I found no solution in the searchable archieves or somewhere else.

I have a square data.frame with distance values. In this special case
the upper and the lower triangle are not the same and the diagonal is
not containing zero.

I need first the lower triangle including the diagonal (but not as
zero) to perform a Manteltest in comparison with another triangle.

I tried first as.dist and it worked very well for the lower triangle
but then I became aware of the diagonal handling as zero.
I found no option to get only the upper triangle including the
diagonal in as.dist.

Secondly i need also the upper triangle including the diagonal to
perform a Manteltest.

Could anybody help me with this problem.

I appologise in advance, because I was  to stupid to find the
solution by myself.

Thanks a lot.

Regards

Birgit

Birgit Lemcke
Institut für Systematische Botanik
Zollikerstrasse 107
CH-8008 Zürich
Switzerland
Ph: +41 (0)44 634 8351
birgit.lemcke at systbot.uzh.ch

```