Skip to content

Instantly share code, notes, and snippets.

@davidtedfordholt
Created May 29, 2024 12:27
Show Gist options
  • Save davidtedfordholt/af8e929d3f8d30657c388fe54f8b5d1e to your computer and use it in GitHub Desktop.
Save davidtedfordholt/af8e929d3f8d30657c388fe54f8b5d1e to your computer and use it in GitHub Desktop.
print object dimensions and size in R
obj_size <- function(obj, units = 'Mb') {
dimensions <- dim(obj)
data.frame(
rows = format(dimensions[1], big.mark = ","),
columns = format(dimensions[2], big.mark = ","),
size = format(object.size(obj), units = units, big.mark = ",")
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment