Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
递归合并或合并R中的两个列表_R_List - Fatal编程技术网

递归合并或合并R中的两个列表

递归合并或合并R中的两个列表,r,list,R,List,我有两张清单: firstList <- list(a = list(a_1 = 1:5, a_2 = 5:10), b = 10, c = list(c_1 = 10:20, c_2 = 20:30)) secondList <- list(b = 9999, c

我有两张清单:

firstList <- list(a = list(a_1 = 1:5,
                           a_2 = 5:10),
                  b = 10,
                  c = list(c_1 = 10:20,
                           c_2 = 20:30))

secondList <- list(b = 9999,
                   c = list(c_2 = 500:505))

换句话说,一个递归地替换两个列表中的元素的函数(某种方式)。

Perfect!这就是我要找的。太好了!这就是我要找的。Related@akrun是的,我希望其他人能找到这两个问题。Related@akrun是的,我希望其他人能找到这两个问题。
modifyList(firstList, secondList)

$a
$a$a_1
[1] 1 2 3 4 5

$a$a_2
[1]  5  6  7  8  9 10


$b
[1] 9999

$c
$c$c_1
 [1] 10 11 12 13 14 15 16 17 18 19 20

$c$c_2
[1] 500 501 502 503 504 505
$a
$a$a_1
[1] 1 2 3 4 5

$a$a_2
[1]  5  6  7  8  9 10


$b
[1] 9999

$c
$c$c_1
 [1] 10 11 12 13 14 15 16 17 18 19 20

$c$c_2
 [1] 500 501 502 503 504 505
modifyList(firstList, secondList)

$a
$a$a_1
[1] 1 2 3 4 5

$a$a_2
[1]  5  6  7  8  9 10


$b
[1] 9999

$c
$c$c_1
 [1] 10 11 12 13 14 15 16 17 18 19 20

$c$c_2
[1] 500 501 502 503 504 505