list.names: Get or set the names of a list by expression

Description Usage Arguments Examples

View source: R/list.names.R

Description

Get or set the names of a list by expression

Usage

1
list.names(.data, expr)

Arguments

.data

A list or vector

expr

the expression whose value will be set as the name for each list element. If missing then the names of the list will be returned. If NULL then the names of the list will be removed.

Examples

1
2
3
4
list.names(c(1,2,3))
list.names(c(a=1,b=2,c=3))
list.names(c(1,2,3),letters[.])
list.names(list(list(name='A',value=10),list(name='B',value=20)), name)

Example output

NULL
[1] "a" "b" "c"
a b c 
1 2 3 
$A
$A$name
[1] "A"

$A$value
[1] 10


$B
$B$name
[1] "B"

$B$value
[1] 20

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