meanranks {crank} | R Documentation |
Calculates mean ranks where some ranks may be missing
meanranks(x,allranks=NULL,labels=NULL,rankx=FALSE)
x |
A matrix of ranks that may contain ties and NAs. Objects ranked are assumed to be columns and ranking methods rows. |
allranks |
An optional list of all ranks that might have been made. |
labels |
Optional labels for the ranks. |
rankx |
Whether to convert competition ranks, or any other set of numeric values, into the usual mean rankings for ties. |
meanranks
calls muranks
to complete the rank matrix
before calculating the mean ranks for each column if there are any
NAs in x
.
Note that cats2ranks
interprets each value in x
as a nominal
level variable and its index as the rank, while meanranks
interprets
values as ordinal level (ranks). Thus if a matrix or data frame of category
labels is passed to meanranks
, it will not give the correct mean
ranks.
A list with the following components:
ranks |
x with any NAs replaced by the mean of unallocated ranks
for each row. |
labels |
The vector of labels, defaulting to the integers 1:allranks. |
mean.ranks |
A vector of mean ranks for each value of allranks. |
Jim Lemon
# simulate "best/worst" ranking x<-matrix(NA,nrow=10,ncol=10) for(i in 1:10) { nbest<-sample(2:5,1) best<-1:nbest nworst<-sample(1:5,1) worst<-(11-nworst):10 rankpos<-sample(1:10,nbest+nworst) x[i,rankpos]<-c(best,worst) } x meanranks(x)