startsToEnds: Helper Function: Start Indices to End Indices

View source: R/blockRange.R

startsToEndsR Documentation

Helper Function: Start Indices to End Indices

Description

helper function to convert start indices to end indices

Usage

startsToEnds(starts, lastStop, stopOffset = 1)

Arguments

starts

vector of integer

lastStop

number to be returned as last element of the result vector

stopOffset

number to be subtracted from (all but the first elements in) starts in order to find the ends

Value

vector of integer

Examples

starts <- c(1, 10, 20, 35)

ok <- identical(
  startsToEnds(starts, lastStop = 50), 
  c(9, 19, 34, 50)
)
  
ok <- ok && identical(
  startsToEnds(starts, lastStop = 50, stopOffset = 2), 
  c(8, 18, 33, 50)
)

ok


KWB-R/kwb.utils documentation built on April 1, 2024, 7:12 a.m.