Created
December 16, 2012 14:17
-
-
Save joshuaulrich/4307717 to your computer and use it in GitHub Desktop.
List objects from current scope by size
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
objSize <- function(n=10, decreasing=TRUE) { | |
# list 'n' objects, sorted by size | |
l <- ls(envir=parent.frame()) | |
N <- seq(min(length(l),n)) | |
x <- setNames(lapply(l, object.size), l) | |
y <- x[order(unlist(x),decreasing=decreasing)] | |
z <- sapply(y, function(a) capture.output(print(a, units="auto"))) | |
return(z[N]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment