chomp: Remove the head and tail of a data structure

Description Arguments Value Usage Details Author(s) See Also Examples

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

1
2
3
4
chomp(1:10)
chomp(letters)

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

lambda.tools documentation built on May 2, 2019, 4:28 a.m.