merge.list: Merge two lists

Description Usage Arguments Value Note See Also Examples

View source: R/utils.R

Description

Merges two lists, taking duplicated elements from the first list.

Usage

1
2
## S3 method for class 'list'
merge(x, y, warn_on_dupes = TRUE, allow_unnamed_elements = FALSE, ...)

Arguments

x

A list.

y

A list.

warn_on_dupes

TRUE or FALSE. Should a warning be given if both x and y have elements with the same name. See note.

allow_unnamed_elements

TRUE or FALSE. Should unnamed elements be allowed?

...

Ignored.

Value

A list, combining elements from x and y.

Note

In the event of elements that are duplicated between x and y, the versions from x are used.

See Also

merge_dots_with_list, merge

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
merge(
  list(foo = 1, bar = 2, baz = 3), 
  list(foo = 4, baz = 5, quux = 6)
)

# If unnamed elements are allowed, they are included at the end
merge(
  list("a", foo = 1, "b", bar = 2, baz = 3, "c"), 
  list(foo = 4, "a", baz = 5, "b", quux = 6, "d"),
  allow_unnamed_elements = TRUE
)

assertive.base documentation built on Feb. 8, 2021, 9:06 a.m.