Skip to content

Commit

Permalink
Merge pull request #86 from adamlilith/solstice2022_2023
Browse files Browse the repository at this point in the history
`memUse()` always returns a `data.frame` uninvisibly
  • Loading branch information
adamlilith authored Sep 28, 2024
2 parents b707915 + d37899a commit c4d34da
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
14 changes: 7 additions & 7 deletions R/memUse.r
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
#' Size of objects taking most memory use
#'
#' Displays the largest objects in memUse.
#' Displays the largest objects in memory
#'.
#' @param n Positive integer: Maximum number of objects to display.
#' @param orderBy Either \code{'size'} (default) or \code{'name'}.
#' @param decreasing Logical, if \code{TRUE} (default), objects are displayed from largest to smallest.
#' @param pos Environment from which to obtain size of objects. Default is 1. See \code{\link{ls}}.#"
#' @param display If \code{TRUE} (default), print a table with memUse used.
#' @param pos Environment from which to obtain size of objects. Default is 1. See \code{\link{ls}}.
#' @param ... Other arguments to pass to \code{\link{ls}}.
#' @return Data frame (invisible).
#'
#' @returns Data frame.
#' @examples
#' memUse()
#' memUse(3)
#' @export

memUse <- function(n=10, orderBy='size', decreasing=TRUE, pos=1, display = TRUE, ...) {
memUse <- function(n=10, orderBy='size', decreasing=TRUE, pos=1, ...) {

out <- sapply(ls(pos=pos, ...), function(x){ utils::object.size(get(x)) })
if (length(out) == 0) {
Expand All @@ -29,7 +30,6 @@ memUse <- function(n=10, orderBy='size', decreasing=TRUE, pos=1, display = TRUE,
out <- as.data.frame(out)
colnames(out) <- 'size'
}
if (display) print(out)
invisible(out)
out

}
18 changes: 5 additions & 13 deletions man/memUse.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c4d34da

Please sign in to comment.