List Lists in R

I have a TF2Gene [1326] list that looks like

view(TF2Gene) structure(list(Sp1=c("a","b","c"),p53=c("x","y","z"),Elk1=c("1","2","3"),...)) 

So this is basically a list of 1326 lists.

Now I want to combine the values ​​of these lists into 1 so that I can find unique members. I'm doing it:

 cols <- unique(unlist(TF2Gene)) 

It is right?

+4
source share
2 answers

Yes, this is the right way to do this. In the above example, the result is a vector of type:

 c("a", "b", "c", "x", "y", "z", "1", "2", "3") 
+4
source

This will only work if your lists have atomic elements. Mine is usually not. Try this instead.

 do.call(c, list (list( 3,4,5 ) , list( "a","b" ))) [[1]] [1] 3 [[2]] [1] 4 [[3]] [1] 5 [[4]] [1] "a" [[5]] [1] "b" 
+2
source

Source: https://habr.com/ru/post/1469300/


All Articles