RobinHankin / hyper2

https://robinhankin.github.io/hyper2/
5 stars 3 forks source link

need a rorder() function like rrank() #41

Open RobinHankin opened 4 years ago

RobinHankin commented 4 years ago

Function rrank() gives a random rank table but we need rorder() to create a table like volvo_table_2014.

RobinHankin commented 4 years ago

One line at a time is easy:

> p <- (9:1)/45
> (x <- rrank(n=1,p))
     c1 c2 c3 c4 c5 c6 c7 c8 c9
[1,]  3  4  2  5  8  6  9  1  7
> order(x)
[1] 8 3 1 2 4 6 9 5 7
> 

Thus player 8 came first, player 3 came second, player 1 came third, and so on.

RobinHankin commented 4 years ago

Currently one needs to specify the pnames argument:

> p <- (5:1)/15
> rrank(2,p,pnames=letters[1:5])
     c1 c2 c3 c4 c5
[1,] a  d  b  c  e 
[2,] b  a  c  e  d 
> 

... but one might expect the following to assign names:

>  p <- (5:1)/15
> names(p) <- letters[1:5]
> rrank(n=1,p)
     c1 c2 c3 c4 c5
[1,]  3  5  1  4  2

and it doesn't.

RobinHankin commented 4 years ago

215ced2837d1182e562fd2a9310b247fe044f624 converts order tables to rank tables, might be relevant.