如何从矩阵列表中调用其名称中具有特定字符串的矩阵?

发布于 2025-01-24 02:39:29 字数 430 浏览 1 评论 0原文

您是否有一个想法只调用我的十二个矩阵列表中包含一串字符的特定矩阵?对于典范,我有十二个矩阵(代表60个个人对之间的遗传距离的数据,因此矩阵为60*60),在一年中的12个月中,我只想提取3个矩阵3个月一年。 因此,我想调用包含其名称“ APR”,“ May”或“ Jun”的矩阵,例如:Spring< - list(List.Mat [[“ APR”]], list.mat [[“ may”],list.mat [[“ jun”]])。但是,由于几个月缺少,我想找到一个只能打电话给几个月的功能,这些功能可能以其名称中包含这些字符串。我尝试grep函数及其派生,但它在矩阵列表上不起作用...
我知道有一种简单的方法可以做到这一点,但我不知道看哪种方式!

我不想手动制作它,因为我有40多个矩阵列表!

感谢您的答复,如果您知道我在寻找什么

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!

I don't want to make it manually because I have more than 40 list of 12 matrices !

Thanks for any replies if you know what i'm looking for

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

酷遇一生 2025-01-31 02:39:29

我们可以使用filterbase r删除null列表元素

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

We may use Filter from base R to remove the NULL list elements

Filter(Negate(is.null), list.mat)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文