n <- 15
x <- rnorm(n)
weights <- 0.9 ^ (n:1)
# rolling index of maximums with complete windows
roll_idxmax(x, width = 5)
# rolling index of maximums with partial windows
roll_idxmax(x, width = 5, min_obs = 1)
# expanding index of maximums with partial windows
roll_idxmax(x, width = n, min_obs = 1)
# expanding index of maximums with partial windows and weights
roll_idxmax(x, width = n, min_obs = 1, weights = weights)
Run the code above in your browser using DataLab