[R] Dimensions of a List

Roland Rau roland.rproject at gmail.com
Tue Mar 25 16:57:16 CET 2008


Hi,

Shubha Vishwanath Karanth wrote:
> l=list(list(c(1,2),c(4,5),c(6,7)),list(c(11,22,33),c(44,55,66)))
> 
> How do I know the dimensions of this list?... In other words, how many
> sub-lists, sub-sub-lists etc...are there in l? How do I know this?
> 
>  

 > l=list(list(c(1,2),c(4,5),c(6,7)),list(c(11,22,33),c(44,55,66)))
 > str(l)
List of 2
  $ :List of 3
   ..$ : num [1:2] 1 2
   ..$ : num [1:2] 4 5
   ..$ : num [1:2] 6 7
  $ :List of 2
   ..$ : num [1:3] 11 22 33
   ..$ : num [1:3] 44 55 66


I hope this is what you were looking for?

Best,
Roland



More information about the R-help mailing list