【发布时间】:2019-10-19 10:47:09
【问题描述】:
我有一个嵌套列表,想打印出某些元素。
下面的示例输入:
list(structure(list(publisherId = 111, categoryId = 42281, levelId = 462,
subcategoryIdList = list(42284), exerciseIdList = list(c(495048,
495047, 495043, 495044, 495045, 495046, 495049, 495050)),
knowledgeBaseEntryIdList = list(list())), class = "data.frame", row.names = 1L),
structure(list(publisherId = 111, categoryId = 41394, levelId = 459,
subcategoryIdList = list(41395), exerciseIdList = list(
c(473272, 473270, 473269, 473262, 473261, 465453,
465452)), knowledgeBaseEntryIdList = list(list())), class = "data.frame", row.names = 1L))
所以该列表包含另一组列表,然后该列表包含另一组列表。
我可以使用下面提到的代码获取单个嵌套列表的值:
t <- myd1[[1]][[5]]
for (i in t) {
print(i)
}
但我不知道,如何围绕这个构建另一个 for 循环。
【问题讨论】: