Being deprecated. Use modifyList (which can not handle NULL) or modifyList2 for case with >2 lists and can handle NULL lists.

updateList(x, y)

Arguments

x

a named list

y

a named list

Value

A named list, with elements sorted by name. The values of matching elements in list y replace the values in list x.

Author

Alex Chubaty

Examples

L1 <- list(a = "hst", b = NA_character_, c = 43) L2 <- list(a = "gst", c = 42, d = list(letters)) updateList(L1, L2)
#> $a #> [1] "gst" #> #> $b #> [1] NA #> #> $c #> [1] 42 #> #> $d #> $d[[1]] #> [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" #> [20] "t" "u" "v" "w" "x" "y" "z" #> #>
updateList(L1, NULL)
#> $a #> [1] "hst" #> #> $b #> [1] NA #> #> $c #> [1] 43 #>
updateList(L1)
#> $a #> [1] "hst" #> #> $b #> [1] NA #> #> $c #> [1] 43 #>
updateList(y = L2)
#> $a #> [1] "gst" #> #> $c #> [1] 42 #> #> $d #> $d[[1]] #> [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" #> [20] "t" "u" "v" "w" "x" "y" "z" #> #>
updateList(NULL, L2)
#> $a #> [1] "gst" #> #> $c #> [1] 42 #> #> $d #> $d[[1]] #> [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" #> [20] "t" "u" "v" "w" "x" "y" "z" #> #>
updateList(NULL, NULL) # should return empty list
#> list()