Learn R Programming

Xmisc (version 0.2.1)

popone,list-method: 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

"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

Examples

Run this code
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"))

Run the code above in your browser using DataLab