To cite the hyper2 package in publications, please use Hankin (2017). Rank tables can be confusing. The package includes a range of functionality for dealing with them. Here, I discuss two cases: firstly, a tiny toy example, and secondly the volvo ocean racing dataset.

Toy dataset

OT <- cbind(1:5,c(1,5,2:4))
rownames(OT) <- letters[seq_len(nrow(OT))]
colnames(OT) <- c("J1","J2")
OT <- ordertable(OT)
OT
## An ordertable:
##   J1 J2
## a  1  1
## b  2  5
## c  3  2
## d  4  3
## e  5  4

Object OT is a straightforward order table, just like skating_table but smaller and simpler. We have two columns, one for each judge (named J1 andJ2), and five competitors, a through e. The first row refers to competitor a; both judges put competitor a first. The second row shows that J1 put b second and J2 put competitor b fifth. If instead we ask who was placed third by each judge, this is not directly given; but by looking for 3 in the table we see that J1 put c third and J2 put d third. To answer this and similar questions directly, we can coerce order table OT to a rank table RT:

RT <- ordertable_to_ranktable(OT)
RT
## A ranktable:
##    c1 c2 c3 c4 c5
## J1 a  b  c  d  e 
## J2 a  c  d  e  b

Object RT gives the same information as OT but in a different form. Note that above we see the print method in action, which uses ranktable_to_printable_object(). Here the rows correspond to the two judges. Each row is a rank vector. Column headings refer to placings (c1 is supposed to be read “came first”, c2 “came second” etc). Looking at the fifth column (c5) we see that J1 and J2 placed e and b fifth respectively.

We can coerce back to an ordertable:

as.ordertable(RT)
## An ordertable:
##   J1 J2
## a  1  1
## b  2  5
## c  3  2
## d  4  3
## e  5  4

Volvo ocean racing dataset

(See volvo.Rd for more details).

volvo_table
## An ordertable:
##            leg1 leg2 leg3 leg4 leg5 leg6 leg7 leg8 leg9
## AbuDhabi   1    3    2    2    1    2    5    3    5   
## Brunel     3    1    5    5    4    3    1    5    2   
## Dongfeng   2    2    1    3    DNF  1    4    7    4   
## MAPFRE     7    4    4    1    2    4    2    4    3   
## Alvimedica 5    5    3    4    3    5    3    6    1   
## SCA        6    6    6    6    5    6    6    1    7   
## Vestas     4    DNF  DNS  DNS  DNS  DNS  DNS  2    6

Thus we see from the first column that in leg 1, AbuDabhi came first, Brunel third, and so on. From the first row we see that AbuDhabi came first in leg 1, third in leg 2, second in leg 3, and so on. Suppose we wish to know who came first in each leg:

x <- wikitable_to_ranktable(volvo_table)
x
## A ranktable:
##      c1         c2       c3         c4         c5         c6         c7      
## leg1 AbuDhabi   Dongfeng Brunel     Vestas     Alvimedica SCA        MAPFRE  
## leg2 Brunel     Dongfeng AbuDhabi   MAPFRE     Alvimedica SCA        Vestas  
## leg3 Dongfeng   AbuDhabi Alvimedica MAPFRE     Brunel     SCA        Vestas  
## leg4 MAPFRE     AbuDhabi Dongfeng   Alvimedica Brunel     SCA        Vestas  
## leg5 AbuDhabi   MAPFRE   Alvimedica Brunel     SCA        Dongfeng   Vestas  
## leg6 Dongfeng   AbuDhabi Brunel     MAPFRE     Alvimedica SCA        Vestas  
## leg7 Brunel     MAPFRE   Alvimedica Dongfeng   AbuDhabi   SCA        Vestas  
## leg8 SCA        Vestas   AbuDhabi   MAPFRE     Brunel     Alvimedica Dongfeng
## leg9 Alvimedica Brunel   MAPFRE     Dongfeng   AbuDhabi   Vestas     SCA

And we see from the first column that AbuDhabi came first in leg 1, Brunel came first in leg 2, Dongfeng came first in leg 3, and so on. The second column shows who came second in each leg. Now suppose we are interested in only the first, second and third-placed teams:

x[,1:3]
##      c1           c2         c3          
## leg1 "AbuDhabi"   "Dongfeng" "Brunel"    
## leg2 "Brunel"     "Dongfeng" "AbuDhabi"  
## leg3 "Dongfeng"   "AbuDhabi" "Alvimedica"
## leg4 "MAPFRE"     "AbuDhabi" "Dongfeng"  
## leg5 "AbuDhabi"   "MAPFRE"   "Alvimedica"
## leg6 "Dongfeng"   "AbuDhabi" "Brunel"    
## leg7 "Brunel"     "MAPFRE"   "Alvimedica"
## leg8 "SCA"        "Vestas"   "AbuDhabi"  
## leg9 "Alvimedica" "Brunel"   "MAPFRE"

The above shows that the extraction method for ranktable objects is not yet written; maybe one day I will get round to implementing [.ranktable() (right now I am not 100% sure that this is a good idea).

References

Hankin, R. K. S. 2017. “Partial Rank Data with the hyper2 Package: Likelihood Functions for Generalized Bradley-Terry Models.” The R Journal 9 (2): 429–39.