Skip to content

Instantly share code, notes, and snippets.

@joshuaulrich
Created December 16, 2012 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshuaulrich/4307717 to your computer and use it in GitHub Desktop.
Save joshuaulrich/4307717 to your computer and use it in GitHub Desktop.
List objects from current scope by size
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