R/size_environment.R

Defines functions weigh_environment

Documented in weigh_environment

#' @title weigh_environment
#' @description Returns size of each object in environment
#'

#' @return Environment object sizes
#' @importFrom tibble tibble
#' @importFrom jsonlite fromJSON
#' @importFrom stringr str_replace_all
#' @importFrom magrittr "%>%"
#' @importFrom stringr str_c
#' @importFrom purrr map
#' @export



weigh_environment <- function(env){
  
  purrr::map_dfr(env, ~ tibble::tibble("object" = .) %>% 
                   dplyr::mutate(size = object.size(get(.x)),
                                 size = as.numeric(size),
                                 megabytes = size / 1000000))
  
}


#' @export
cgpeltier/cgp documentation built on March 26, 2021, 7:40 p.m.