Thread: [R-gregmisc-users] SF.net SVN: r-gregmisc:[1366] trunk/gdata/R/ll.R
Brought to you by:
warnes
From: <ar...@us...> - 2009-11-16 12:58:10
|
Revision: 1366 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1366&view=rev Author: arnima Date: 2009-11-16 12:57:47 +0000 (Mon, 16 Nov 2009) Log Message: ----------- ll(.GlobalEnv) does not crash anymore Modified Paths: -------------- trunk/gdata/R/ll.R Modified: trunk/gdata/R/ll.R =================================================================== --- trunk/gdata/R/ll.R 2009-11-12 15:38:53 UTC (rev 1365) +++ trunk/gdata/R/ll.R 2009-11-16 12:57:47 UTC (rev 1366) @@ -51,7 +51,7 @@ { object.frame <- data.frame() } - else if(search()[pos] == "Autoloads") # pos is the autoload environment + else if(environmentName(as.environment(pos)) == "Autoloads") { object.frame <- data.frame(rep("function",length(ls(pos,...))), rep(0,length(ls(pos,...))), row.names=ls(pos,...)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2013-06-28 21:22:42
|
Revision: 1683 http://sourceforge.net/p/r-gregmisc/code/1683 Author: warnes Date: 2013-06-28 21:22:40 +0000 (Fri, 28 Jun 2013) Log Message: ----------- Add on.exit() handler to ensure a matching detach occurs when attach is used in ll() Modified Paths: -------------- trunk/gdata/R/ll.R Modified: trunk/gdata/R/ll.R =================================================================== --- trunk/gdata/R/ll.R 2013-06-28 20:29:06 UTC (rev 1682) +++ trunk/gdata/R/ll.R 2013-06-28 21:22:40 UTC (rev 1683) @@ -38,7 +38,7 @@ { if(length(pos) == 0) return(data.frame()) - attach(pos, pos=2, warn.conflicts=FALSE) + attach(pos, pos=2, warn.conflicts=FALSE); on.exit(detach(pos=2)) original.rank <- rank(names(pos)) was.list <- TRUE pos <- 2 @@ -79,7 +79,7 @@ } if(was.list) { - detach(pos=2) + detach(pos=2); on.exit() if(!sort) object.frame <- object.frame[original.rank, ] } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2013-06-29 01:37:23
|
Revision: 1691 http://sourceforge.net/p/r-gregmisc/code/1691 Author: warnes Date: 2013-06-29 01:37:19 +0000 (Sat, 29 Jun 2013) Log Message: ----------- Simplify ll() by stuffing list arguments into an environment, avoiding the need to use attach/detach. Modified Paths: -------------- trunk/gdata/R/ll.R Modified: trunk/gdata/R/ll.R =================================================================== --- trunk/gdata/R/ll.R 2013-06-28 22:01:04 UTC (rev 1690) +++ trunk/gdata/R/ll.R 2013-06-29 01:37:19 UTC (rev 1691) @@ -35,18 +35,7 @@ if(is.character(pos)) # pos is an environment name pos <- match(pos, search()) if(is.list(pos)) # pos is a list-like object - { - if(length(pos) == 0) - return(data.frame()) - attach(pos, pos=2, warn.conflicts=FALSE); on.exit(detach(pos=2)) - original.rank <- rank(names(pos)) - was.list <- TRUE - pos <- 2 - } - else - { - was.list <- FALSE - } + pos <- as.environment(pos) if(length(ls(pos,...)) == 0) # pos is an empty environment { object.frame <- data.frame() @@ -77,12 +66,6 @@ object.frame <- cbind(object.frame, Dim=sapply(ls(pos,...),get.object.dim,pos=pos)) } - if(was.list) - { - detach(pos=2); on.exit() - if(!sort) - object.frame <- object.frame[original.rank, ] - } if(!is.null(class)) { include <- object.frame$Class %in% class This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ar...@us...> - 2013-12-18 14:33:31
|
Revision: 1758 http://sourceforge.net/p/r-gregmisc/code/1758 Author: arnima Date: 2013-12-18 14:33:28 +0000 (Wed, 18 Dec 2013) Log Message: ----------- Retain original list order unless sort=FALSE; also stop if unnamed list Modified Paths: -------------- trunk/gdata/R/ll.R Modified: trunk/gdata/R/ll.R =================================================================== --- trunk/gdata/R/ll.R 2013-12-16 19:58:56 UTC (rev 1757) +++ trunk/gdata/R/ll.R 2013-12-18 14:33:28 UTC (rev 1758) @@ -29,13 +29,21 @@ return(size) } + ## 1 Set unit, denominator, original.rank unit <- match.arg(unit, c("bytes","KB","MB")) denominator <- switch(unit, "KB"=1024, "MB"=1024^2, 1) + original.rank <- NULL + ## 2 Detect what 'pos' is like, then get class, size, dim if(is.character(pos)) # pos is an environment name pos <- match(pos, search()) if(is.list(pos)) # pos is a list-like object + { + if(is.null(names(pos))) + stop("All elements of a list must be named") + original.rank <- rank(names(pos)) pos <- as.environment(pos) + } if(length(ls(pos,...)) == 0) # pos is an empty environment { object.frame <- data.frame() @@ -66,6 +74,12 @@ object.frame <- cbind(object.frame, Dim=sapply(ls(pos,...),get.object.dim,pos=pos)) } + + ## 3 Retain original order of list elements + if(!sort && !is.null(original.rank)) + object.frame <- object.frame[original.rank,] + + ## 4 Filter results given class if(!is.null(class)) { include <- object.frame$Class %in% class This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |