[R] Matrix to list object

Henrique Dallazuanna wwwhsd at gmail.com
Mon Dec 28 12:43:44 CET 2009


Try this:

mat_list <- lapply(split(mat, seq(nrow(mat))), matrix, ncol = 3)

On Mon, Dec 28, 2009 at 9:20 AM, Ron_M <ron_michael70 at yahoo.com> wrote:
>
> let consider following matrix :
>
> mat <- matrix(rnorm(45), 15)
>
> Now I want  to convert it to a list object "mat_list", which will have 15
> elements and each element will again be a matrix with 3 rows and 3 columns.
>
> How can I do that?
>
> Thanks,
> --
> View this message in context: http://n4.nabble.com/Matrix-to-list-object-tp989738p989738.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O




More information about the R-help mailing list