[R-gregmisc-users] SF.net SVN: r-gregmisc:[1691] trunk/gdata/R/ll.R
Brought to you by:
warnes
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. |