How do I concatenate two lists in R in such a way that duplicate elements from the second one will override corresponding elements from the first one?
I tried c()
, but it keeps duplicates:
l1 <- list(a = 1, b = 2)
l1 <- c(l1, list(b = 3, c = 4))
# $a
# [1] 1
#
# $b
# [1] 2
#
# $b
# [1] 3
#
# $c
# [1] 4
I want something that will produce this instead:
# $a
# [1] 1
#
# $b
# [1] 3
#
# $c
# [1] 4
Hope that there exists something simpler than calling some *apply function?