search for: sortlevel

Displaying 1 result from an estimated 1 matches for "sortlevel".

Did you mean: sortlevels
2007 Apr 18
2
Computing an ordering on subsets of a data frame
If I have a data frame X that looks like this: A B - - 1 2 1 3 1 4 2 3 2 1 2 1 3 2 3 1 3 3 and I want to make another column which has the rank of B computed separately for each value of A. I.e. something like: A B C - - - 1 2 1 1 3 2 1 4 3 2 3 3 2 1 1 2 1 2 3 2 2 3 1 1 3 3 3 by(X, X[,1], function(x) { rank(x[,1], ties.method="random") } ) almost seems to work, but the data is not