ordertrans: Order transformation

ordertransR Documentation

Order transformation

Description

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

Usage

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 file inst/ordertrans.Rmd 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

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.Rd). 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.

Author(s)

Robin K. S. Hankin

See Also

rrank

Examples


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

o <- skating_table[,1]
names(o) <- rownames(skating_table)
o
ordertrans(o)

ordertrans(sample(icons_maxp),icons)


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")


hyper2 documentation built on Aug. 21, 2022, 1:05 a.m.