Created
December 1, 2023 17:48
-
-
Save jmbarbone/5bbdc3dee72ce9c2034b6fec2c281430 to your computer and use it in GitHub Desktop.
Find the largest object in a namespace
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
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