previous_i: Find the ith previous index

Description Usage Arguments Details Examples

View source: R/0-Functions.R

Description

Find the ith previous index while avoiding 0 or negative indexes.

Usage

1
previous_i(x, n_prev)

Arguments

x

Current index

n_prev

Target number of indexes before x

Details

This function is used to find the nth previous index without making an error with negative or 0 index.

Examples

1
2
3
4
5
# Find the 10th index before 15:
previous_i(15,10)
# Find the 10th index before 5:
previous_i(5,10)
# should return 1 (no index before 1)

VEZY/DynACof documentation built on Feb. 3, 2021, 8:52 p.m.