Last active
April 9, 2018 13:56
-
-
Save vankesteren/a0fc7c6f73c8abfc0f3b8e44b0fa41a8 to your computer and use it in GitHub Desktop.
Display object sizes from large to small with human-readable formatting. It's a really ugly function with a double sapply in there, but it does its job well.
This file contains hidden or 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
| object.sizes <- function(unit = "auto", all = FALSE) { | |
| data.frame(size = | |
| sapply( | |
| sort( | |
| sapply(ls(envir = parent.frame(), all.names = all), function(x) { | |
| object.size(get(x, envir = parent.frame())) | |
| }), | |
| decreasing = TRUE | |
| ), | |
| function(y) { | |
| utils:::format.object_size(y, unit = unit) | |
| } | |
| ) | |
| ) | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to load & use