delete_at {container} | R Documentation |
Delete Elements at Indices Safely
Description
Search and remove values at given indices, which can be numeric or character or both. If any given index is invalid, an error is signaled. Indices can be numbers or names or both.
Usage
delete_at(.x, ...)
ref_delete_at(.x, ...)
## S3 method for class 'Container'
delete_at(.x, ...)
## S3 method for class 'Container'
ref_delete_at(.x, ...)
## S3 method for class 'dict.table'
delete_at(.x, ...)
## S3 method for class 'dict.table'
ref_delete_at(.x, ...)
Arguments
.x |
any |
... |
indices at which values are to be deleted. |
Value
For Container
, an object of class Container
(or one of the
respective derived classes).
For dict.table
, an object of class dict.table
.
Examples
co = container(a = 1, b = 2, 3)
delete_at(co, "a", "b") # [3]
delete_at(co, 1:2) # [3]
delete_at(co, "a", 3) # [b = 2]
try({
delete_at(co, 4) # index out of range
delete_at(co, "x") # names(s) not found: 'x'
})
dit = as.dict.table(head(sleep))
dit
delete_at(dit, "ID")
delete_at(dit, "ID", 1)
try({
delete_at(dit, "foo") # Column 'foo' not in dict.table
})
[Package container version 1.0.4 Index]