copy: Copy elements of a list

Description Usage Arguments Value Author(s) See Also Examples

Description

Copies elements of a list, either indexed or named

Usage

1
copy(x, index = 1:length(x))

Arguments

x

list, unnamed or named

index

integer or character index of the elements in x to copy, either indexed integer or named character

Value

list

Author(s)

Thomas P. Harte

See Also

list

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
 # NULL list:
	copy(list(), integer(0))

	# unnamed list:
 x<- list(1, 2, 3)
 x

 copy(x, integer(0))
 copy(x, 1:2)

 # named list:
 x<- list(a=1, b=2, c=3)
 x
 # integer index still works:
 copy(x, 1:2)
 # named index works too:
 copy(x, c("a","b"))

 ## FIXME: index mismatch
 ## copy(x, 1:4)
 ## copy(x, c("a","b"))
 ## copy(x, c("a","b","d"))

tharte/tutils documentation built on Feb. 11, 2020, 9:17 a.m.