I generated 1000 2x2 random matrices with:
M=lapply(1:1000, function(z) matrix(runif(1000,min=-10,max=10), ncol = 2, nrow = 2)) eig=lapply(M, eigen)
Thank you so much in advance!
We can extract the 'values' from a list using [[ by looping over the elements of list with sapply and this is done with base R
[[
list
sapply
out <- c(sapply(eig, `[[`, "values")) plot(out)
Or with pluck
pluck
library(tidyverse) map(eig, pluck, "values") %>% unlist
If you want a base R solution you can turn this into a
mats <- matrix(unlist(lapply(e, function(x) lapply(x, unlist)$values)), ncol = 2, byrow = T)