I want to extract one matrix of a list of matrices. However, this extracted matrix should not be a list anymore. Probably it is very easy to do this, but I can not find the solution. Here some example data:
x = list(a = matrix(sample(1:5,4) , nrow=2, ncol=2),
b = matrix(sample(5:10,4) , nrow=2, ncol=2),
c = matrix(sample(10:15,4) , nrow=2, ncol=2))
I selected one of the matrices by name (which is important in my case, as I have more than 1000 matrices), but it is still a list of one item:
new <- x["b"]
I tried as.matrix(new)
which returns something different. And also lapply(new, function(r){r["b"]})
. My question: how to extract one matrix, with str()=matrix and not list?
Thanks