Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to call matrices which have a specific character string in their name from a list of matrices?

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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

Filter(Negate(is.null), list.mat)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading