R/create.duplexes.R

Defines functions create.duplexes

Documented in create.duplexes

#' Create duplexes 
#' 
#' Given a length (n) create a matrix of indexes as duplexes.
#' This is useful when comparing neighbouring vector elements.
#' For example for sequence [1,2,3,4] n=4 yielding a matrix where first row is [1,2], second row is [2,3], third row is [3,4].
#' @param n Numeric of sequence of indexes length
#' @return Matrix of duplexes where pairs occupy rows
#' @author Alexander Kheirallah ([email protected])
#' @export 

create.duplexes = function(n){
  col1 = seq(1,n-1,by=1)
  col2 = seq(2,n,by=1)
  o = unname(cbind(col1,col2))
  o
}
msxakk89/dat documentation built on April 3, 2020, 5:39 p.m.