Sample ranks of a time series
baserank.Rd
Compute the sample ranks of the values of a 'timeSeries' object.
Arguments
 x
an univariate object of class
timeSeries
. na.last

for controlling the treatment of
NA
s. IfTRUE
, missing values in the data are put last; ifFALSE
, they are put first; ifNA
, they are removed; if"keep"
they are kept with rankNA
.  ties.method

a character string specifying how ties are treated; can be abbreviated.
Details
If all components are different (and no NA
s), the ranks are
well defined, with values in seq_len(x)
. With some values equal
(called ‘ties’), argument ties.method
determines the
result at the corresponding indices. The "first"
method results
a permutation with increasing values at each index set of ties. The
"random"
method puts these in random order, whereas the
default, "average"
, replaces them by their mean, and
"max"
and "min"
replace them with their maximum and
minimum respectively, the latter being the typical sports ranking.
NA
values are never considered to be equal: for na.last =
TRUE
and na.last = FALSE
they are given distinct ranks in the
order in which they occur in x
.
Examples
## Load Microsoft Data 
X < 100 * returns(MSFT)
## Compute the Ranks 
head(rank(X[, "Open"]), 10)
#> GMT
#> Open
#> 20000928 18
#> 20000929 138
#> 20001002 107
#> 20001003 87
#> 20001004 8
#> 20001005 86
#> 20001006 147
#> 20001009 122
#> 20001010 44
#> 20001011 132
## Only Interested in the Vector, then use 
head(rank(series(X[, "Open"])), 10)
#> [1] 18 138 107 87 8 86 147 122 44 132