【发布时间】:2019-08-12 06:54:22
【问题描述】:
示例列表:
sublist <- list(foo = "foo", bar = "bar", baz = "baz")
sample_list <- list(a = sublist,
b = sublist,
c = sublist)
在这里,我想在上述每个列表中为 a b 和 c 中的元素创建一个子列表。即我想嵌套foo、bar、baz,再往下嵌套一个列表,在我以上述方式创建列表之后。
期望的输出:
sample_list <- list(a = list(a_down = sublist),
b = list(b_down = sublist),
c = list(c_down = sublist))
【问题讨论】:
-
类似
lapply(1:3, function(i) setNames(list(sublist), letters[i]))?