Back
I have two lists
first = list(a = 1, b = 2, c = 3)second = list(a = 2, b = 3, c = 4)
first = list(a = 1, b = 2, c = 3)
second = list(a = 2, b = 3, c = 4)
I want to merge these two lists so the final product is
$a[1] 1 2$b[1] 2 3$c[1] 3 4
$a
[1] 1 2
$b
[1] 2 3
$c
[1] 3 4
Is there a simple function to do this?
You can use the mapply function to merge two lists if they have the same structure.i.e.,
first = list(a = 1, b = 2, c = 3)second = list(a = 2, b = 3, c = 4)mapply(c, first, second, SIMPLIFY=FALSE)
mapply(c, first, second, SIMPLIFY=FALSE)
Output:
31k questions
32.8k answers
501 comments
693 users