startsToRanges: Row Numbers of Start Rows to From/To Row Ranges

View source: R/blockRange.R

startsToRangesR Documentation

Row Numbers of Start Rows to From/To Row Ranges

Description

A vector of row numbers is transformed to a data frame describing row ranges by numbers of first and last rows

Usage

startsToRanges(starts, lastStop, startOffset = 1, stopOffset = 1)

Arguments

starts

integer vector of start indices

lastStop

integer value of the last stop index

startOffset

integer offset applied to the starts

stopOffset

integer offsets applied to the ends

Value

data frame with columns from and to

Examples

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

ok <- identical(
  startsToRanges(starts, lastStop = 50), 
  data.frame(
    from = c(2, 11, 21, 36),
    to = c(9, 19, 34, 50)
  )
)
  
ok <- ok && identical(
  startsToRanges(starts, lastStop = 55, startOffset = 2, stopOffset = 2), 
  data.frame(
    from = c(3, 12, 22, 37),
    to = c(8, 18, 33, 55)
  )
)
  
ok
  

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