Do you have an idea to call only one specific matrix which contain a string of characters in my list of twelve matrices ? For exemple, I have my list of twelve matrices (which represent data of genetic distance between pairs of 60 individuals, a matrix is therefore 60*60) for the 12 months of the year, and I want to extract only 3 matrices for 3 months of the year. So for that, I want to call the matrices which contain in their name "Apr", "May" or "Jun", like this : spring <- list(list.mat[["Apr"]], list.mat[["May"]], list.mat[["Jun"]]). But because there is missing months, I want to find a function who call only the months who can possibly contain these string of charactrs in their names. I try grep function and its derivates but it doesn't work on list of matrices...
I know there is a simple way to do that but I don't know which way to look!

我不想手工制作,因为我有超过40个12个矩阵的列表!

如果你知道我在找什么,谢谢你的回复

推荐答案

我们可以使用base R中的Filter来删除NULL个列表元素

Filter(Negate(is.null), list.mat)

R相关问答推荐

使用spatVector裁剪网格数据时出现的问题

整数成随机顺序与约束R?

par函数中的缩写,比如mgp,mar,mai是如何被破译的?

使用列/行匹配将两个不同维度的矩阵相加

以更少间隔的较小表中的聚合离散频率表

在RStudio中堆叠条形图和折线图

如何在R中平滑地绘制线图(不拟合)?

安全地测试文件是否通过R打开

在数据帧列表上绘制GGPUP

调换行/列并将第一行(原始数据帧的第一列)提升为标题的Tidyr类似功能?

如何使用字符串从重复的模式中提取多个数字?

在同一单元格中创建包含整数和百分比的交叉表

如果满足条件,则替换列的前一个值和后续值

是什么打破了此Quarto仪表板中的工具提示?

删除r中每个因素级别的最后2行

用逗号拆分字符串,并删除一些字符

如何在给定的环境中找到函数的函数参数?

如何根据分位数及其值创建格式化字符串值的数组?

我应该如何解决Raster程序包中未对齐的色条记号?

有没有一种方法可以在pivot_longer()中 Select 最后一列,而不需要命名或给出索引号?