且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

替换列表列表中的元素

更新时间:2022-05-27 22:09:21

一种选择是先unlist列表x,然后替换名为的值"a",然后根据x的列表结构relist新列表u.

One option would be to first unlist the list x, then replace the values named "a", and then relist the new list u based on the list structure of x.

u <- unlist(x)
u[names(u) == "a"] <- 10:12
relist(u, x)