RAnEn::mergeList combine two lists. It does not allow names in conflict unless the name is further a list. This is similar to a depth-first copy for list variables.
mergeList(from, to, names)
A list to copy from
A list to copy to
the names to copy, usually names(from)
library(RAnEn)
from <- list(C = list(C = 3, D = list(A = 1)), D = 3)
to <- list(A = 1, B = 2, C = list(A = 1, B = 2))
merged <- mergeList(from, to, names(from))
print(from, recursive = T)
#> $C: list: [2]
#> $C: value: 3
#> $D: list: [1]
#> $A: value: 1
#> $D: value: 3
print(to, recursive = T)
#> $A: value: 1
#> $B: value: 2
#> $C: list: [2]
#> $A: value: 1
#> $B: value: 2
print(merged, recursive = T)
#> $A: value: 1
#> $B: value: 2
#> $C: list: [4]
#> $A: value: 1
#> $B: value: 2
#> $C: value: 3
#> $D: list: [1]
#> $A: value: 1
#> $D: value: 3