You have assumed everything as I meant it.
I understand what is happening now. ls() simply creates a vector with
character elements and dim() sees each element as not having dimensions. The
critical part of what you have shown is the get(command) that turns what is
just a string into the dataframe or vector whose name is the string. The
other issue which you showed, and one that I have come across before is that
sapply and tapply and lapply cannot handle a function on a function. I would
have thought that I should get the same result from

lapply(ls(),dim(get())) or something such as that.

But instead one has to create a function command within the lapply to handle
a dimension command upon a get command.


On 1/9/07, Barry Rowlingson <b.rowlingson@lancaster.ac.uk> wrote:
>
> 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
>
>


-- 
Farrel Buchinsky
Mobile: (412) 779-1073

	[[alternative HTML version deleted]]

