pop: Remove items

Description Usage Arguments Value Examples

View source: R/pop.R

Description

pop is a generic function that will remove the item at the given position.

Usage

1
2
3
4
5
6
7
pop(x, i = length(x))

## Default S3 method:
pop(x, i = length(x))

## S3 method for class 'list'
pop(x, i = length(x))

Arguments

x

An appropriate R object.

i

Integer position of the element to be removed in x. Defaults to removing the last element of x.

Value

Returns the object x with the i-th element removed.

Examples

1
2
3
4
5
6
7
8
x <- 1:3
y <- letters[1:3]
z <- as.list(x)
names(z) <- y
pop(x)
pop(y, 2)  # remove the second element
pop(y, -2)  # remove everythng except the second element
for (i in 1:3) print(z <- pop(z))

bgreenwell/bmisc documentation built on Sept. 24, 2019, 11:09 a.m.