Skip to content

Instantly share code, notes, and snippets.

@jmbarbone
Created December 1, 2023 17:48
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 jmbarbone/5bbdc3dee72ce9c2034b6fec2c281430 to your computer and use it in GitHub Desktop.
Save jmbarbone/5bbdc3dee72ce9c2034b6fec2c281430 to your computer and use it in GitHub Desktop.
Find the largest object in a namespace
largest_ns_object <- function(ns, mode = "any") {
ns <- asNamespace(ns)
sizes <- vapply(
ls(ns, all.names = TRUE),
\(x) utils::object.size(get0(x, ns, mode = mode)),
NA_real_
)
sizes[which.max(sizes)]
}
largest_ns_object("base")
largest_ns_object("utils")
largest_ns_object("tools")
largest_ns_object("dplyr")
largest_ns_object("fuj")
largest_ns_object("mark")
largest_ns_object("mark", "function")
largest_ns_object("openxlsx2")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment