merge.list: Merge a list with another object

Description Usage Arguments Value Examples

View source: R/utils.R

Description

Concatenates two lists, preserving order but dropping elements with duplicated names from the second list. If the second parameter is not a list, it will be converted to one with as.list. Names must be unique within each list but may be (and probably are) duplicated between them. Unnamed elements are allowed and are always kept.

Usage

1
2
## S3 method for class 'list'
merge(x, y, ...)

Arguments

x

A list

y

A value to merge, general a list but if not it will be converted to a list using as.list

...

Unused, present only for compatibility with the generic.

Value

A list equal to the first list followed by the second list without any of its named elements already included in the first list.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
first  <- list( "x1", x2name="x2", shared3="in x", "x4" )
second <- list( "y1", y2name="y2", shared3="in y", "y4" )
combined <- merge( first, second )
want <- list( "x1", x2name="x2", shared3="in x", "x4",
              "y1", y2name="y2",                 "y4" )
all.equal( combined, want )
#> TRUE

charVec <- c( "y1", y2name="y2", shared3="in y", "y4" )
combinedWithVec <- merge( first, charVec )
all.equal( combinedWithVec, want )
#> TRUE

JefferysAnalysis/ComplexRmd documentation built on Dec. 18, 2021, 12:35 a.m.