How to extract elements from list of lists
Another way is to use unlist
:
> t1=list(list(c("a","control")),list(c("b","disease1")))
> t1
[[1]]
[[1]][[1]]
[1] "a" "control"
[[2]]
[[2]][[1]]
[1] "b" "disease1"
> matrix(unlist(t1),ncol=2,byrow=TRUE)
[,1] [,2]
[1,] "a" "control"
[2,] "b" "disease1"
rapply
offers yet another option:
unique(rapply(t1, function(x) head(x, 1)))