Last data update: 2014.03.03

R: Remove the head and tail of a data structure
chompR Documentation

Remove the head and tail of a data structure

Description

Remove the specified number of elements from either the head or tail of a data structure.

Arguments

x

Any indexable data structure

head

The number of elements to be removed from the head of x

tail

The number of elements to be removed from the tail of x

Value

A data structure with the head and tail chomped off

Usage

chomp(x, head=1, tail=1)

Details

This function is inspired by the PERL function of the same name. While the PERL version is designed for strings, this version is designed for any indexable data structure, typically containing numbers.

Author(s)

Brian Lee Yung Rowe

See Also

pad

Examples

chomp(1:10)
chomp(letters)

chomp(data.frame(x=1:10, y=1:10), head=2, tail=2)

Results