tag:blogger.com,1999:blog-7556813435224291579.post1387217914123071006..comments2023-03-23T10:46:08.543+00:00Comments on One R Tip A Day: ls() improved!Paolohttp://www.blogger.com/profile/01969817827028660433noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-7556813435224291579.post-25232054552824550412010-04-17T14:21:52.599+01:002010-04-17T14:21:52.599+01:00This is really cool!!! :)) love it!!This is really cool!!! :)) love it!!Consuelohttps://www.blogger.com/profile/03286751213439799209noreply@blogger.comtag:blogger.com,1999:blog-7556813435224291579.post-3668719619794455732009-06-16T08:33:28.852+01:002009-06-16T08:33:28.852+01:00You're welcome! Thanks for your useful contrib...You're welcome! Thanks for your useful contribution, I really appreciate it!Paolohttps://www.blogger.com/profile/01969817827028660433noreply@blogger.comtag:blogger.com,1999:blog-7556813435224291579.post-66044220245856540402009-06-15T20:25:09.106+01:002009-06-15T20:25:09.106+01:00A very handy little function but I did a slight mo...A very handy little function but I did a slight modification to order output by class (see below). Thanks for the very helpful blog!!<br /><br />#ls() improved!<br />#from One R Tip A Day by Paolo<br />#<br />#This marvelous little function shows all objects in the current workspace<br />#by mode, class and 'size'! Thanks to Bendix Carstensen!<br /><br />lls <- function (pos = 1, pat = "")<br /><br />{<br /><br /> dimx <- function(dd) if (is.null(dim(dd)))<br /><br /> length(dd)<br /><br /> else dim(dd)<br /><br /> lll <- ls(pos = pos, pat = pat)<br /> #jack's mod<br /> #######################################<br /> class.get <- function(x){class(get(x))}<br /> lll2 <- lapply(lll, class.get)<br /> a <- order(unlist(lll2))<br /> lll <- lll[a]<br /> #######################################<br /><br /> cat(formatC("mode", 1, 15), formatC("class", 1, 18),<br /><br /> formatC("name",1, max(nchar(lll)) + 1), "size\n-----------------------------------------------------------------\n")<br /><br /> if (length(lll) > 0)<br /><br /> {<br /><br /> for (i in 1:length(lll))<br /><br /> {<br /><br /> cat(formatC(eval(parse(t = paste("mode(", lll[i],<br /><br /> ")"))), 1, 15), formatC(paste(eval(parse(t = paste("class(",<br /><br /> lll[i], ")"))), collapse = " "), 1, 18), formatC(lll[i],<br /><br /> 1, max(nchar(lll)) + 1), " ", eval(parse(t = paste("dimx(", lll[i], ")"))), "\n")<br /><br /> }<br /><br /> }<br /><br />}Unknownhttps://www.blogger.com/profile/18231040473291429773noreply@blogger.com