R 递归列表的lappy提供了不正确的维度

R 递归列表的lappy提供了不正确的维度,r,R,我有一个递归列表,我想对它执行一些函数 例如: subset_list<-list(A=list(kan=data.frame(corr=seq(1,10),Lib=rep("Kan",times=10),pheno1=seq(11,20),pheno2=seq(20,11)),Cm=data.frame(corr=seq(1,10),Lib=rep("Cm",times=10),pheno1=seq(1,10),pheno2=seq(10,1)),all=data.frame(corr=

我有一个递归列表,我想对它执行一些函数

例如:

subset_list<-list(A=list(kan=data.frame(corr=seq(1,10),Lib=rep("Kan",times=10),pheno1=seq(11,20),pheno2=seq(20,11)),Cm=data.frame(corr=seq(1,10),Lib=rep("Cm",times=10),pheno1=seq(1,10),pheno2=seq(10,1)),all=data.frame(corr=seq(1,20),Lib=rep("AQ",times=20),pheno1=seq(1,20),pheno2=seq(20,1))),B=list(kan=data.frame(corr=seq(1,10),Lib=rep("Kan",times=10),pheno1=seq(11,20),pheno2=seq(20,11)),Cm=data.frame(corr=seq(10,20),Lib=rep("Cm",times=11),pheno1=seq(10,20),pheno2=seq(20,10)),all=data.frame(corr=seq(20,40),Lib=rep('AQ',times=21),pheno1=seq(0,20),pheno2=seq(20,0))))

subset\u list很难重现,因为在您的示例中找不到
INTlist
corr
。抱歉,我编辑了它,INTlist应该是subset\u list(我有两个相同维度的列表),而corr在我的示例中找到,它是DataFrames中的一个变量。我仍然不清楚您想做什么。你能给我们看看你想要的产量吗?您的第二行也可以使用
density\u subset\u列表进行简化
density_subset_list<-lapply(subset_list,function(x) lapply(lapply(x,'[[','corr'),density))
for (i in 1:length(subset_list)){
    subset_list_excLowPheno<-lapply(subset_list[[i]],function(x) subset(x,x$pheno1 > 10 & x$pheno2 > 10 ))
}