This function takes two named lists and merges them recursively. Values in
the second list (b
) override or extend those in the first list (a
).
If both a
and b
contain a named list at the same position, they are merged recursively.
Arguments
- a
A named list to be updated.
- b
A named list containing values to override or add to a
.
Value
A named list that is the result of merging b
into a
.
Examples
a <- list(x = list(y = 1, z = 2), foo = "bar")
b <- list(x = list(y = 42, new = 99), foo = "baz", extra = "new_value")
merge_lists(a, b)
#> $x
#> $x$y
#> [1] 42
#>
#> $x$z
#> [1] 2
#>
#> $x$new
#> [1] 99
#>
#>
#> $foo
#> [1] "baz"
#>
#> $extra
#> [1] "new_value"
#>