list.remove: Remove members from a list by index or name

Description Usage Arguments Examples

View source: R/list.remove.R

Description

Remove members from a list by index or name

Usage

1

Arguments

.data

A list or vector

range

A numeric vector of indices or a character vector of names to remove from .data

Examples

1
2
3
4
5
x <- list(p1 = list(type='A',score=list(c1=10,c2=8)),
       p2 = list(type='B',score=list(c1=9,c2=9)),
       p3 = list(type='B',score=list(c1=9,c2=7)))
list.remove(x, 'p1')
list.remove(x, c(1,2))

Example output

$p2
$p2$type
[1] "B"

$p2$score
$p2$score$c1
[1] 9

$p2$score$c2
[1] 9



$p3
$p3$type
[1] "B"

$p3$score
$p3$score$c1
[1] 9

$p3$score$c2
[1] 7



$p3
$p3$type
[1] "B"

$p3$score
$p3$score$c1
[1] 9

$p3$score$c2
[1] 7

rlist documentation built on Sept. 5, 2021, 5:30 p.m.