Remove and return an element from a list

Description

Remove and return an element from an R object, given name or index. Default: the last element Note: the R object is altered in place, like Python List pop()

Usage

1
2
## S4 method for signature 'list'
popone(obj, x, warn = TRUE, error = TRUE)

Arguments

obj

an R object

x

name or index

warn

logical, whether warn at error

error

logical, whether stop at error

Value

the element and the R object is altered in place

Author(s)

Xiaobei Zhao

Examples

1
2
3
4
5
ll <- list(1,2,3,a=4,b=5,6,7,c=8,9)
popone(ll,"a")
popone(ll,1) ## remove the 1st in ll
popone(ll,1) ## remove the next (2nd of the origin)
try(popone(list(),"a"))

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.