Re: [R] dimensions of a all objects

From: BXC (Bendix Carstensen) <bxc_at_steno.dk>
Date: Wed 10 Jan 2007 - 11:33:43 GMT


Generally it is difficult to get an overview of what's there. But the following function I acquired from (???) ages ago does a nice job:

lls <-
function (pos = 1, pat = "")
{

    dimx <- function(dd) if (is.null(dim(dd)))

        length(dd)
    else dim(dd)
    lll <- ls(pos = pos, pat = pat)
    cat(formatC("mode", 1, 15), formatC("class", 1, 18), formatC("name",

        1, max(nchar(lll)) + 1), "

size\n-------------------------------------------------------\n")
    if (length(lll) > 0) {
        for (i in 1:length(lll)) {
            cat(formatC(eval(parse(t = paste("mode(", lll[i], 
                ")"))), 1, 15), formatC(paste(eval(parse(t =
paste("class(", 
                lll[i], ")"))), collapse = " "), 1, 18), formatC(lll[i],

                1, max(nchar(lll)) + 1), " ", eval(parse(t =
paste("dimx(", 
                lll[i], ")"))), "\n")
        }

    }
}

Just say

lls()

and you get a reasnoable listing of obejcts.

Best,
Bendix


Bendix Carstensen
Senior Statistician
Steno Diabetes Center
Niels Steensens Vej 2-4
DK-2820 Gentofte
Denmark

+45 44 43 87 38 (direct)
+45 30 75 87 38 (mobile)
+45 44 43 73 13 (fax)

bxc_at_steno.dk http://www.biostat.ku.dk/~bxc

> -----Original Message-----

> From: Farrel Buchinsky [mailto:fjbuch@gmail.com] 
> Sent: Tuesday, January 09, 2007 3:30 PM
> To: r-help@stat.math.ethz.ch
> Subject: [R] dimensions of a all objects
> 
> 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))
> --
> Farrel Buchinsky
> 
> 	[[alternative HTML version deleted]]
> 
> 
>

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed Jan 10 22:38:43 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 Wed 10 Jan 2007 - 12:30:30 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.