【发布时间】:2020-08-11 11:47:37
【问题描述】:
我有一个名为 AllVotes 的复杂嵌套列表,您可以在此处找到(在 .rds 中):
https://github.com/JMcrocs/MEPVote/blob/master/FinalVotes.rds
我正在尝试收集所有mepid,这是一个存储在子列表AllVotes[[x]]$votes$'+'$groups 中的命名号码。感谢之前的问题,我可以为一个列表([[1]] 列表)做到这一点,但我想对我的巢列表的所有列表从 [[1]] 到 [[2336] ].
#For the list [[1]]
Result = c(unlist( sapply ( names ( AllVotes[[1]]$votes$'+'$groups ),
function(x) unlist( AllVotes[[1]]$votes$'+'$groups[[x]] ) ) ),
unlist( sapply ( names ( AllVotes[[1]]$votes$'-'$groups ),
function(x) unlist( AllVotes[[1]]$votes$'-'$groups[[x]] ) )),
unlist( sapply ( names ( AllVotes[[1]]$votes$'0'$groups ),
function(x) unlist( AllVotes[[1]]$votes$'0'$groups[[x]] ) )))
我该怎么做?提前谢谢你!
PS:抱歉,如果问题不完美,我对编程(和溢出)还有两周的时间。
【问题讨论】:
-
您能否提供
dput(AllVotes)或类似结果的可重复性? -
@niko Sadmu,dput(AllVotes) 太大,无法提供
标签: r nested-lists sapply