[R] storage of matrices of diff dimension together
Sarah Goslee
sarah.goslee at gmail.com
Thu May 10 20:43:37 CEST 2012
Hi Carol,
> m1 <- rbind(c(1,2),c(3,4),c(5,6))
> m2 <- rbind(c(1,2),c(5,6))
> mylist <- list(m1)
> c(mylist, list(m2))
[[1]]
[,1] [,2]
[1,] 1 2
[2,] 3 4
[3,] 5 6
[[2]]
[,1] [,2]
[1,] 1 2
[2,] 5 6
See the examples in ?c for more information.
Sarah
On Thu, May 10, 2012 at 2:35 PM, carol white <wht_crl at yahoo.com> wrote:
> Hi,
> It might be a trivial question but how do you store matrices of different dimensions read from a file or in a loop together? The best solution might be a list but I don't store the first matrix correctly:
>
> m = rbind(c(1,2),c(3,4),c(5,6))
> t=rbind(c(1,2),c(5,6))
>
>
> l = list(m)
>> l = list(l,t) #I assumed that at the begining I don't have m and t at the same time to do list(m,t), but I list them, one after the other
>> l
> [[1]]
> [[1]][[1]]
> [,1] [,2]
> [1,] 1 2
> [2,] 3 4
> [3,] 5 6
>
>
> [[2]]
> [,1] [,2]
> t 1 2
> 5 6
>
>
> thanks
>
> Carol
>
--
Sarah Goslee
http://www.functionaldiversity.org
More information about the R-help
mailing list