consec.pairs: Generate a matrix of consecutive pairs

Description Usage Arguments Value Examples

View source: R/consec.pairs.R

Description

Generates a two-column matrix consisting of consecutive pairs from the input vector. This function in useful for functions that need to be applied to consecutive elements in a vector.

Usage

1
consec.pairs(elements)

Arguments

elements

A vector of elements for which consecutive pairs are desired. Elements can be of any class.

Value

A two-column matrix is returned. Each row of the matrix consists of two consecutive elements of the input vector. All consecutive pairs are included.

Examples

1
2
3
V <- 1:5
consec.pairs(V)
V

Example output

Warning messages:
1: In rgl.init(initValue, onlyNULL) : RGL: unable to open X11 display
2: 'rgl_init' failed, running with rgl.useNULL = TRUE 
3: .onUnload failed in unloadNamespace() for 'rgl', details:
  call: fun(...)
  error: object 'rgl_quit' not found 
     [,1] [,2]
[1,]    1    2
[2,]    2    3
[3,]    3    4
[4,]    4    5
[1] 1 2 3 4 5

cape documentation built on May 2, 2019, 3:27 a.m.