Skip to content
Prev 241032 / 398500 Next

arrays of arrays

Hello Sachin,

You have a "ragged array" and you can easily store this as a list of vectors...

x <- list(c(0,0,1,1), c(1,3,5), 4, c(7, -1, 8, 9, 10, 6))

The only gotcha with this is that you will then need to use double
brackets for the first index when retrieving values (single brackets
will return a vector wrapped in a list)...

e.g. x[[2]][3] gives 5

You can query vector length with double brackets...

e.g. length( x[[2]] ) gives 3

Hope this helps,

Michael
On 10 November 2010 16:00, <sachinthaka.abeywardana at allianz.com.au> wrote: