[R] matrix of bins with different length

Gabor Grothendieck ggrothendieck at gmail.com
Tue Jul 10 17:38:16 CEST 2007


Try this:

> m <- matrix(list(1, 1:2, 1:3, 1:4), 2)
> m[[1,1]]
[1] 1
> m[[2,1]]
[1] 1 2
> m
     [,1]      [,2]
[1,] 1         Integer,3
[2,] Integer,2 Integer,4


On 7/10/07, Balazs Torma <torma at sztaki.hu> wrote:
> Dear users,
>
>    please help to define the following data structure:
>
> I would like to have a matrix, where every element is a container of
> different size , containing real numbers. The containers (bins) are
> addressed by an index pair [i,j] (i is number of corresponding row of
> the matrix, j is the coloumn of the matrix). The containers are
> initially empty, I would like to fill them dynamically (put certain
> numbers into different bins in each iteration).
>
> I can not define a 3 dimensional array, because I don't know the
> length of the third dimension in advance, and because the vectors
> (containers) in the matrix are usually of different length.
>
> Any help greatly appreciated,
> Balazs Torma
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>



More information about the R-help mailing list