[R] dimensions of a all objects

BXC (Bendix Carstensen) bxc at steno.dk
Wed Jan 10 12:33:43 CET 2007


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 at gmail.com] 
> Sent: Tuesday, January 09, 2007 3:30 PM
> To: r-help at 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]]
> 
> 
>



More information about the R-help mailing list