list_override: Add/Replace Elements of First List with Elements of Second...

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

Adds each element of list2 to list1, overriding any elements of the same name. Similar to modifyList function in utils package, but either list can be NULL. Useful for do.call statements, when you want to combine a list of default inputs with a list of user-specified inputs.

Usage

1
list.override(list1, list2)

Arguments

list1

Initial list that has some number of named elements. Can be NULL or an empty list.

list2

List with named elements that will be added to list1, replacing any elements with the same name. Can be NULL or an empty list.

Details

NA

Value

A list containing the named elements initially in list1 and not in list2, any additional named elements in list2, and any named elements in list1 that were replaced by elements of the same name in list2.

Note

NA

Author(s)

Dane R. Van Domelen

References

Acknowledgment: This material is based upon work supported by the National Science Foundation Graduate Research Fellowship under Grant No. DGE-0940903.

See Also

modifyList, do.call

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Create list that has default inputs to the plot function
list.defaults <- list(x = 1: 5, y = 1: 5, type = "l", lty = 1)

# Create list of user-specified inputs to the plot function
list.user <- list(main = "A Straight Line", lty = 2, lwd = 1.25)

# Combine the two lists into one, giving priority to list.user
list.combined <- list.override(list.defaults, list.user)

# Plot data using do.call
do.call(plot, list.combined)

stocks documentation built on May 2, 2019, 5:22 p.m.