merge.list: Merge two lists

View source: R/listUtils.R

merge.listR Documentation

Merge two lists

Description

Merges two lists, appending the second to the first. Expects that all elements are named and that within a list, all names are unique. If the same name is used in both lists, the element (value) from the second list is kept, the one from the first list is dropped. That results in the order of elements in the merged list being different. If keepOrder = TRUE is set, then the order of elements in the first list is kept with the duplicated elements from the second dropped.

Usage

## S3 method for class 'list'
merge(x, y, keepOrder = FALSE, ...)

Arguments

x

A list

y

Another list

keepOrder

How to order the list when duplicates occur: by default this is FALSE, with duplicates dropped from x when they have the same name as an element in y, before appending y. If TRUE, preserves the order of element names as much as possible, by replacing the value of duplicated element names with those from y, then appending y with duplicated elements dropped.

...

Required for generic method. Not used.

Value

A list consisting of all elements from x not also in y, and then all elements in y, or


jefferys/JefferysRUtils documentation built on Jan. 12, 2024, 9:18 p.m.