Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

base-rank

Sample Ranks of a Time Series


Description

Returns the sample ranks of the values of a 'timeSeries' object.

Usage

## S4 method for signature 'timeSeries'
rank(x, na.last = TRUE, ties.method = )

Arguments

x

an univariate object of class timeSeries.

na.last

for controlling the treatment of NAs. If TRUE, missing values in the data are put last; if FALSE, they are put first; if NA, they are removed; if "keep" they are kept with rank NA.

ties.method

a character string specifying how ties are treated; can be abbreviated.

Details

If all components are different (and no NAs), the ranks are well defined, with values in seq_len(x). With some values equal (called ???ties???), the argument ties.method determines the result at the corresponding indices. The "first" method results in 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" replaces them by 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.

Value

returns the ranks of a timeSeries object.

Examples

## Load Microsoft Data -
   X <- 100 * returns(MSFT)

## Compute the Ranks -
   head(rank(X[, "Open"]), 10)
   
## Only Interested in the Vector, then use -
   head(rank(series(X[, "Open"])), 10)

timeSeries

Financial Time Series Objects (Rmetrics)

v3062.100
GPL (>= 2)
Authors
Diethelm Wuertz [aut] (original code), Tobias Setz [cre], Yohan Chalabi [ctb], Martin Maechler [ctb] (<https://orcid.org/0000-0002-8685-9910>)
Initial release
2020-01-24

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.