Skip to contents

Long listing of R session objects

Usage

lldf(
  n = Inf,
  envir = -1L,
  items = NULL,
  use_utils_objectsize = TRUE,
  all.names = TRUE,
  ...
)

Arguments

n

integer or Inf indicating how many objects to include in the output data.frame.

envir

environment where the list of objects is obtained, default -1L searches the environment of the caller, usually the user workspace. Other recognized options:

  • character string suitable for as.environment() which recognizes the search path returned by search()

  • integer or numeric equivalent to environment relative position as used in ls() argument pos.

items

character of items to include, default NULL.

use_utils_objectsize

logical, default TRUE, whether to prefer utils::object.size(), otherwise it will attempt to use pryr::object_size() if the package is installed.

all.names

logical passed to base::ls() indicating whether to include all names, where all.names=TRUE will include hidden objects whose name begin with "." such as ".First".

...

additional arguments are passed to ls(), notably pattern can be passed to subset objects by regular expression.

Value

data.frame with summary of objects and object sizes, sorted by decreasing object size.

Details

This function expands base::ls() by also determining the object size, and sorting to display the top n objects by size, largest first.

This package will call pryr::object_size if available, otherwise falls back to utils::object.size().

Examples

lldf(10);
#> $size
#> character(0)
#> 

# custom environment
newenv <- new.env();
newenv$A <- 1:10;
newenv$df <- data.frame(A=1:10, B=11:20);
lldf(envir=newenv);
#>    name      class bytes      size
#> df   df data.frame   944 944 bytes
#> A     A    integer    96  96 bytes
rm(newenv);