[prev in list] [next in list] [prev in thread] [next in thread]
List: r-help
Subject: Re: [R] rank() vs SAS proc rank
From: Gabor Grothendieck <ggrothendieck () myway ! com>
Date: 2004-03-31 1:33:17
Message-ID: loom.20040331T032312-96 () post ! gmane ! org
[Download RAW message or body]
This afternoon (EST) there were solutions to two different problems,
which on reflection have a similarity:
Prof Brian Ripley's rank variation:
1 + rowSums(outer(x, x, ">"))
and my unique row counts:
"%all.==%" <- function(a,b)apply(b,2,function(x)apply(t(a) == x,2,all))
colSums( A %all.==% t(unique(A)) )
It occurred to me that if we define the APL-style
generalized matrix multiply like this:
inner <- function(a,b,f,g){
f <- match.fun(f)
g <- match.fun(g)
apply(b,2,function(x)apply(g(t(a),x),2,f))
}
then both problems can be put into a similar form:
1+inner( t(w), t(w), sum, "<" )
and
colSums( inner( A, t(unique(A)), all, "==" ) )
______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic