Jeff, you can do
> sum1: \sum_i\sum_j max(X_i,X_j) > sum2: \sum_i\sum_j max(Y_i,Y_j) sum(x * (2 * rank(x) - 1)) > sum3: \sum_i\sum_j max(X_i,Y_j) sum(outer(x, y, pmax)) Probably, the latter can be speeded up even more... Z ______________________________________________ R-help@stat.math.ethz.ch 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.