I guess your data frame is a little different from the reference, so your as.logical doesn't work.
attach(Q) FUN <- function(X, Y) {abs(X - Y)} round(outer(rank(date)[colour=="b"],rank(date)[colour=="g"],FUN) + outer(rank(number)[colour=="b"],rank(number)[colour=="g"],FUN)) detach(Q) ----- A R learner. -- View this message in context: http://r.789695.n4.nabble.com/discrepancy-matrix-tp2291126p2291585.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.