[R] dimensions of a all objects

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Tue Jan 9 15:53:05 CET 2007


Farrel Buchinsky wrote:
> Why will the following command not work
> sapply(objects(),dim)
> What does it say about the objects list? What does it say about the dim
> command?
> 
> Likewise, the following also does not work
> all<-ls()
> for (f in all) print(dim(f))

   'objects()' returns character strings - the names of objects - then 
the dim of the character strings are all NULL.

  I'll assume that's what you are getting at - you've not posted an 
example or the output you are getting or why it 'does not work'.

  Maybe you want this:
  > sapply(objects(),function(x){dim(get(x))})
  $f
  NULL

  $m
  [1] 2 5

  $x
  NULL

  $y
  [1] 5 2

  - where m and y are matrices, f is a function, x is a scalar.

Barry



More information about the R-help mailing list