如何组织R中列表列表的输出

如何组织R中列表列表的输出,r,R,假设这是我的列表(我想组织结果,因为我的数据包含超过40个结果,我很难手动组织它们) 也许是这样的 # From your code, create a list L L <- lapply(setNames(HH, paste0(names1, '_Model')), function(x) setNames(x, paste0('Res_', seq_along(x)))) # get all x-th elements from the list, and add them t

假设这是我的列表(我想组织结果,因为我的数据包含超过40个结果,我很难手动组织它们)


也许是这样的

# From your code, create a list L
L <- lapply(setNames(HH, paste0(names1, '_Model')), function(x) 
  setNames(x, paste0('Res_', seq_along(x))))
# get all x-th elements from the list, and add them to new list L2
L2 <- lapply( 1:length(L[[1]]), function(x) {
  lapply(L, "[[", x)  
})
# set names of L2
names(L2) <- names(L[[1]])

问题是如何将嵌套列表从“模型编号>结果编号”重新排列为“结果编号>模型编号”

我想要的是类似的东西


请澄清你的目标。您的意思是要重新排列列表,使所有
resu 1
显示在所有
resu 2
之前,然后依次显示
resu 3
resu 4
,等等。@LC datascientist是的。这就是我想要的。感谢您的评论,并尝试提供帮助。
 #$First_Model
#$First_Model$Res_1
#[1] 1 2 3
 
  
  #$Second_Model
#$Second_Model$Res_1
#[1] 4 8 7

   #$First_Model$Res_2
#[1] 4 5 6
    
    #$Second_Model$Res_2
#[1] 0 3 4
# From your code, create a list L
L <- lapply(setNames(HH, paste0(names1, '_Model')), function(x) 
  setNames(x, paste0('Res_', seq_along(x))))
# get all x-th elements from the list, and add them to new list L2
L2 <- lapply( 1:length(L[[1]]), function(x) {
  lapply(L, "[[", x)  
})
# set names of L2
names(L2) <- names(L[[1]])
# $Res_1
# $Res_1$First_Model
# [1] 1 2 3
# 
# $Res_1$Second_Model
# [1] 4 8 7
# 
# 
# $Res_2
# $Res_2$First_Model
# [1] 4 5 6
# 
# $Res_2$Second_Model
# [1] 0 3 4
#$Res_1
#$Res_1$First_Model
#[1] 1 2 3
#
#$Res_1$Second_Model
#[1] 4 8 7
#
#
#$Res_2
#$Res_2$First_Model
#[1] 4 5 6
#
#$Res_2$Second_Model
#[1] 0 3 4