Re: [R] dimensions of a all objects

From: Martin Maechler <>
Date: Tue 09 Jan 2007 - 15:09:20 GMT

>>>>> "BaRow" == Barry Rowlingson <> >>>>> on Tue, 09 Jan 2007 14:53:05 +0000 writes:

    BaRow> 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))

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

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

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

    BaRow> $m
    BaRow> [1] 2 5

    BaRow> $x
    BaRow> NULL

    BaRow> $y
    BaRow> [1] 5 2

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

Since he's just interested in "print"ing, maybe

   ls.str() # would be even more revealing (or maybe too

             # confusing for a newbie)

Martin mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Wed Jan 10 05:13:55 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 09 Jan 2007 - 19:31:46 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.