meanranks: Calculate mean ranks with possible missing values

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Calculates mean ranks where some ranks may be missing

Usage

1
 meanranks(x,allranks=NULL,labels=NULL,rankx=FALSE)

Arguments

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.

Details

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.

Value

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.

Author(s)

Jim Lemon

See Also

muranks, rank, cats2ranks

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
 # 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)

Example output

      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
 [1,]    8    3    2    9    5   NA    4    1   NA    10
 [2,]   NA   NA   10    3    4    5    8    9    1     2
 [3,]    8    2    1   10   NA   NA   NA    9   NA    NA
 [4,]    1   NA   NA   10    2    9   NA    6    8     7
 [5,]   NA    1   NA   NA    9    2   NA   10   NA     3
 [6,]   NA   NA    3   NA   NA   10   NA   NA    1     2
 [7,]    1   NA   10   NA   NA    2    3   NA    9     4
 [8,]   NA   10   NA   NA   NA    2    9   NA    1    NA
 [9,]    3   NA   10    9    4    1   NA    2    7     8
[10,]    1    8    9    7    4    3    2   10   NA    NA

	Mean rank
6	4.55
1	4.65
9	5
5	5.15
10	5.2
2	5.3
7	5.3
3	6.05
8	6.55
4	7.25

crank documentation built on May 1, 2019, 9:39 p.m.

Related to meanranks in crank...