Learn R Programming

lambda.tools (version 1.0.9)

chomp: 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.

See Also

pad

Examples

Run this code
chomp(1:10)
chomp(letters)

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

Run the code above in your browser using DataLab