Skip to content

Instantly share code, notes, and snippets.

@diazdc
Created January 8, 2020 19:04
Show Gist options
  • Save diazdc/de1dc9c3ac9d9ff334535200444870f7 to your computer and use it in GitHub Desktop.
Save diazdc/de1dc9c3ac9d9ff334535200444870f7 to your computer and use it in GitHub Desktop.
Print R environment variable sizes
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