Hello,

Try the following.

# Create the dataset
Table1 <- matrix(10:6, ncol = 1)
rownames(Table1) <- letters[1:5]
Table1

t(outer(Table1[,1], Table1[,1], `-`))

Hope this helps,

Rui Barradas
Em 10-11-2012 18:32, cleberchaves escreveu:
Hello all,
i would like to calculate the difference of all row values and the others
row values from my matrix (table 1). The output (table 2) would be a matrix
with input matrix's row names on row names and colums names, thereby the
difference values among two of the row names could be bether found.

Could someone help me?

Examples:

          Table 1:
          a         10
          b         9
          c         8
          d         7
          e         6


          Table 2:
                   a         b         c         d         e
          a       0        -1        -2        -3        -4
          b       1        0         -1        -2        -3
          c        2        1         0        -1         -2
          d       3        2         1          0         1
          e       4        3         2          1          0



--
View this message in context: 
http://r.789695.n4.nabble.com/matrix-of-all-difference-between-rows-values-tp4649191.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to