Given an order vector, shuffle so that the players appear in a specified order.

ordertrans(x,players)
ordertransplot(ox,oy,plotlims, ...)

Arguments

x

A (generalized) order vector

players

A character vector specifying the order in which the players will be listed; if missing, use sort(names(x))

ox,oy

Rank vectors

plotlims

Length two numeric vector giving x and y plot limits. If missing, use sensible default

...

Further arguments, passed to plot()

Details

The best way to describe this function is with an example:


> x <- c(d=2,a=3,b=1,c=4)
> x
d a b c
2 3 1 4

In the above, we see x is an order vector showing that d came second, a came third, b came first, and c came fourth. This is difficult to deal with because one has to search through the vector to find a particular competitor, or a particular rank. This would be harder if the vector was longer. If we wish to answer the question “where did competitor a come? where did b come?” we would want an order vector in which the competitors are in alphabetical order. This is accomplished by ordertrans():


> o <- ordertrans(x)
> o
a b c d
3 1 4 2

(this is equivalent to o <- x[order(names(x))]). Object o contains the same information as x, but presented differently. This says that a came third, b came first, c came fourth, and d came second. In particular, the Plackett-Luce order statistic is identical:


> ordervec2supp(x) == ordervec2supp(o)
> [1] TRUE

There is a nice example of ordertrans() in inst/eurovision.Rmd, and package vignette ordertrans provides further discussion and examples.

Function ordertrans() takes a second argument which allows the user to arrange an order vector into the order specified.

Function ordertrans() also works in the context of hyper3 objects:


x <- c(d=2,a=3,b=1,a=4)
x
d a b a
2 3 1 4
ordertrans(x)
a a b d
3 4 1 2

Object x shows that d came second, a came third and fourth, and b came first. We can see that ordertrans() gives the same information in a more intelligible format. This functionality is useful in the context of hyper3 likelihood functions.

Value

Returns a named vector

Author

Robin K. S. Hankin

Note

The argument to ordertrans() is technically an order vector because it answers the question “where did the first-named competitor come?” (see the discussion at rrank). But it is not a helpful order vector because you have to go searching through the names—which can appear in any order—for the competitor you are interested in. I guess “generalised order vector” might be a better description of the argument.

See also

Examples


x <- c(e=4L,a=7L,c=6L,b=1L,f=2L,g=3L,h=5L,i=8L,d=9L)
x
#> e a c b f g h i d 
#> 4 7 6 1 2 3 5 8 9 
ordertrans(x,letters[1:9])
#> a b c d e f g h i 
#> 7 1 6 9 4 2 3 5 8 

o <- skating_table[,1]
names(o) <- rownames(skating_table)
o
#>      hughes   slutskaya        kwan       cohen      suguri  butyrskaya 
#>           1           3           2           5           4           6 
#>    robinson   sebestyen    kettunen   volchkova maniachenko     fontana 
#>           7           8           9          10          13          14 
#>   liashenko        onda      hubert       meier   gusmeroli   soldatova 
#>          15          11          12          16          17          19 
#>       hegel     giunchi   babiakova       kopac        luca 
#>          20          18          22          21          23 
ordertrans(o)
#>   babiakova  butyrskaya       cohen     fontana     giunchi   gusmeroli 
#>          22           6           5          14          18          17 
#>       hegel      hubert      hughes    kettunen       kopac        kwan 
#>          20          12           1           9          21           2 
#>   liashenko        luca maniachenko       meier        onda    robinson 
#>          15          23          13          16          11           7 
#>   sebestyen   slutskaya   soldatova      suguri   volchkova 
#>           8           3          19           4          10 

ordertrans(sample(icons_maxp),icons)
#>         NB          L         PB        THC         OA       WAIS 
#> 0.25230411 0.17364433 0.22458188 0.17011281 0.11068604 0.06867083 


rL <- volvo_maxp   # rL is "ranks Likelihood"
rL[] <- rank(-volvo_maxp)

r1 <- volvo_table[,1]  # ranks race 1
names(r1) <- rownames(volvo_table)
ordertransplot(rL,r1,xlab="likelihood rank, all races",ylab="rank, race 1")