Description Usage Arguments Details Value Examples
Given (X1,Y1),...,(Xn,Yn), many nonparametric statistics depend only
on the permutation P that satisfies rank Yi = P[rank Xi].
The function relative_order
computes such P given X1,...,Xn and Y1,...,Yn.
1 | relative.order(xs, ys, na.rm = TRUE, collisions = TRUE)
|
xs, ys |
Numeric vectors of same length. |
na.rm |
Logical: Should missing values, |
collisions |
Logical: Warn of repeating values in |
By default, the function removes missing values, and warns of
repeating values.
Then it computes the relative order by calling the base R function
order
twice: order(xs[order(ys)])
.
Ties may be broken arbitrarily, depending on the behavior of the function
order
.
An integer vector which describes the ordering of the second argument
ys
, in terms of the ordering of the corresponding values in the
first argument xs
.
For example, if xs[3]
is the i
th smallest
and ys[3]
is the j
th smallest,
then the returned value in position i
is j
.
1 2 3 4 5 6 7 8 9 | relative.order(1:5, c(10,30,50,40,20))
## [1] 1 3 5 4 2
relative.order(c(1,2,5,3,4), c(10,30,50,40,20))
## [1] 1 3 4 2 5
set.seed(123)
relative.order(runif(8), runif(8))
## [1] 5 4 8 1 3 2 7 6
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.