[R] discrepancy matrix

nero holzmannlukas at gmail.com
Fri Jul 16 11:15:54 CEST 2010


Hi!

I want to create a discrepancy matrix.
I have got a data.frame Q:

      number     colour     date
2     343            b        1503
3     678           g         1701
4     347            b        1904
5     345            b        2001
6     123           g         1809

Now i want to create a matrix, whose entries are the total differences
between the ranks of number and date for each pair ( a pair is a combination
, made of different colours (zB. 2,3  or 2,6)).
(343-678)+(1503-1701) = -533

( if my explanation is too bad, you can look up for a equivalent example on
this page:http://www.stat.lsa.umich.edu/~bbh/optmatch/doc/optmatch.pdf   (
on page 5))


I tried this code:
 plantdist<-round(outer(rank(' date')[as.logical('colour')],rank('
date')[!as.logical('colour')],
 FUN = function(X, Y) {
  abs(X - Y)
 }) + outer(rank( 'number ')[as.logical('colour')], rank( 'number
')[!as.logical('colour')],
 FUN = function(X, Y) {
 abs(X - Y)
  }))
With the result: <NA>  

And im over this problem since two days, i´m sure, that the answer is not so
difficult...bit i can´t find it ...
So i hoped , that you could help me=)


-- 
View this message in context: http://r.789695.n4.nabble.com/discrepancy-matrix-tp2291126p2291126.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list