Created
January 8, 2020 19:04
-
-
Save diazdc/de1dc9c3ac9d9ff334535200444870f7 to your computer and use it in GitHub Desktop.
Print R environment variable sizes
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
for (i in seq_along(ls())) { | |
objects <- ls() | |
obj_size <- object.size(get(objects[i])) | |
cat("\n") | |
print(objects[i]) | |
if (obj_size > 1 * 10^9) { | |
print(obj_size, units = "GB") | |
} else if (obj_size > 1 * 10^6) { | |
print(obj_size, units = "MB") | |
} else {print(obj_size)} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment