[R] Matrix of Matrices?

Petr Savicky savicky at praha1.ff.cuni.cz
Tue Feb 15 21:16:26 CET 2011


On Tue, Feb 15, 2011 at 09:40:54AM -0800, Alaios wrote:
> Thank you very much for your help again.
> One more question is that after I have that list of matrices what is the easiest way to find the minimun and maximum values of ALL the matrices in that list? 

Try the following.

  # get a list of random matrices 
  rndmat <- function() matrix(runif(4), 2, 2)
  lst <- replicate(4, rndmat(), simplify=FALSE)
 
  # maximum of all components
  max(unlist(lst))

  # vector of the maxima
  sapply(lst, max)

Hope this helps.

Petr Savicky.



More information about the R-help mailing list