#' Run invisible garbage collection
#'
#' @description
#' Run garbage collection without the `gc()` output. Can also be run in the middle of a long pipe chain. Useful for large datasets.
#'
#' @param .data Optional. If null runs `gc()` silently. Else returns the same object unaltered.
#' @export
#'
#' @examples
#' inv_gc()
#'
#' df %>%
#' inv_gc() %>%
#' select(col1, col2)
inv_gc <- function(.data = NULL) {
if(missing(.data)) {
invisible(gc())
} else {
invisible(gc())
return(.data)
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.