Skip to content

help with one matrix

4 messages · Jose Claudio Faria, Gabor Grothendieck

#
Dear R-list,

Could anybody tell me how to make one matrix as the below:

      [,1] [,2] [,3] [,4] [,5] [,6]
[1,]    -    2    3    4    5    6
[2,]    2    -    2    3    4    5
[3,]    3    2    -    2    3    4
[4,]    4    3    2    -    2    3
[5,]    5    4    3    2    -    2
[6,]    6    5    4    3    2    -

Thanks in advance,
#
On 9/10/05, Jose Claudio Faria <joseclaudio.faria at terra.com.br> wrote:
Assuming that - means NA 

dd <- diag(NA, 6)
abs(col(dd) - row(dd)) + 1 + dd

or

abs(outer(1:6, 1:6, "-")) + 1 + diag(NA,6)

or

f <- function(x,y) ifelse(x==y, NA, abs(x-y)+1)
outer(1:6, 1:6, f)
#
Gabor Grothendieck wrote:

            
Hi,

You are always solving (and teaching) my R doubts: thanks Gabor, very much!
Because I need one, I've been trying to make a more flexible function for 
multiple comparison test of means (Tukey, SNK and Duncan). The matrix above is 
necessary for SNK and Duncan tests. So, when running I will to sent it for you 
for suggestions.

Best,
#
On 9/11/05, Jose Claudio Faria <joseclaudio.faria at terra.com.br> wrote:
Note that there already exists a TukeyHSD function and you might
want to do an RSiteSearch for the others to see what
is available.