Skip to contents

Search and remove values at given indices, which can be numeric or character or both. Invalid indices are ignored.

Usage

discard_at(.x, ...)

ref_discard_at(.x, ...)

# S3 method for class 'Container'
discard_at(.x, ...)

# S3 method for class 'Container'
ref_discard_at(.x, ...)

# S3 method for class 'dict.table'
discard_at(.x, ...)

# S3 method for class 'dict.table'
ref_discard_at(.x, ...)

Arguments

.x

any R object.

...

indices at which values are to be discarded.

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)
discard_at(co, "a", "b")         # [3]
#> [3]
discard_at(co, 1:2)              # [3]
#> [3]
discard_at(co, "a", 3)           # [b = 2]
#> [b = 2]
discard_at(co, "x")              # ignored
#> [a = 1, b = 2, 3]

dit = as.dict.table(head(sleep))
discard_at(dit, "ID")
#> <dict.table> with 6 rows and 2 columns
#>    extra  group
#>    <num> <fctr>
#> 1:   0.7      1
#> 2:  -1.6      1
#> 3:  -0.2      1
#> 4:  -1.2      1
#> 5:  -0.1      1
#> 6:   3.4      1
discard_at(dit, "ID", 1)
#> <dict.table> with 6 rows and 1 column
#>     group
#>    <fctr>
#> 1:      1
#> 2:      1
#> 3:      1
#> 4:      1
#> 5:      1
#> 6:      1
discard_at(dit, "foo")  # ignored
#> <dict.table> with 6 rows and 3 columns
#>    extra  group     ID
#>    <num> <fctr> <fctr>
#> 1:   0.7      1      1
#> 2:  -1.6      1      2
#> 3:  -0.2      1      3
#> 4:  -1.2      1      4
#> 5:  -0.1      1      5
#> 6:   3.4      1      6