Learn R Programming

gor (version 2.0)

next_index: Next position to i in a cycle

Description

Next position to i in a cycle.

Usage

next_index(i, n)

Value

The next position in cycle

Arguments

i

Position in cycle

n

Length of cycle

Author

Cesar Asensio

Details

In a cycle, the next slot to the i-th position is i+1 unless i=n. In this case, the next is 1.

Examples

Run this code
next_index(5, 7)   # 6
next_index(7, 7)   # 1

Run the code above in your browser using DataLab