Re: [R] How to create a matrix from a list without a for loop

2021-07-09 Thread Duncan Murdoch
On 09/07/2021 3:37 p.m., Laurent Rhelp wrote: Very effective solution, I hope I remember that for the nex time. The key things to remember are that in R a "list" object is a vector whose elements are R objects, and that matrices are just vectors with dimension attributes. Those two ideas a

Re: [R] How to create a matrix from a list without a for loop

2021-07-09 Thread Laurent Rhelp
Very effective solution, I hope I remember that for the nex time. Thank you Le 09/07/2021 à 19:50, David Winsemius a écrit : On 7/9/21 10:40 AM, Laurent Rhelp wrote: Dear R-Help-list,   I have a list init_l containing 16 dataframes and I want to create a matrix 4 x 4 from this list with a

Re: [R] How to create a matrix from a list without a for loop

2021-07-09 Thread Laurent Rhelp
You are right, this extra level disturbed me. Very impressive this solution, thank you very much. Le 09/07/2021 à 19:50, Bill Dunlap a écrit : > Try >    matrix(init_l, nrow=4, ncol=4, > dimnames=list(c("X1","X2","X3","X4"),c("X1","X2","X3","X4"))) > It doesn't give exactly what your code does

Re: [R] How to create a matrix from a list without a for loop

2021-07-09 Thread David Winsemius
On 7/9/21 10:40 AM, Laurent Rhelp wrote: Dear R-Help-list,   I have a list init_l containing 16 dataframes and I want to create a matrix 4 x 4 from this list with a dataframe in every cell of the matrix. I succeeded to do that but my loop is very uggly (cf. below). Could somebody help me to

Re: [R] How to create a matrix from a list without a for loop

2021-07-09 Thread Bill Dunlap
Try matrix(init_l, nrow=4, ncol=4, dimnames=list(c("X1","X2","X3","X4"),c("X1","X2","X3","X4"))) It doesn't give exactly what your code does, but your code introduces an extra level of "list", which you may not want. -Bill On Fri, Jul 9, 2021 at 10:40 AM Laurent Rhelp wrote: > Dear R-Help-li

[R] How to create a matrix from a list without a for loop

2021-07-09 Thread Laurent Rhelp
Dear R-Help-list,   I have a list init_l containing 16 dataframes and I want to create a matrix 4 x 4 from this list with a dataframe in every cell of the matrix. I succeeded to do that but my loop is very uggly (cf. below). Could somebody help me to write nice R code to do this loop ? Thank