Learn R Programming

cape (version 2.0.2)

consec.pairs: Generate a matrix of consecutive pairs

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

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

Run this code
V <- 1:5
consec.pairs(V)
V

Run the code above in your browser using DataLab