Learn R Programming

butcher (version 0.3.5)

axe-formula: Axing formulas.

Description

formulas might capture an environment from the modeling development process that carries objects that will not be used for any post- estimation activities.

Usage

# S3 method for formula
axe_env(x, verbose = FALSE, ...)

Value

Axed formula object.

Arguments

x

A model object.

verbose

Print information each time an axe method is executed. Notes how much memory is released and what functions are disabled. Default is FALSE.

...

Any additional arguments related to axing.

Examples

Run this code
wrapped_formula <- function() {
  some_junk_in_environment <- runif(1e6)
  ex <- as.formula(paste("y ~", paste(LETTERS, collapse = "+")))
  return(ex)
}

lobstr::obj_size(wrapped_formula())
lobstr::obj_size(butcher(wrapped_formula()))

wrapped_quosure <- function() {
  some_junk_in_environment <- runif(1e6)
  out <- rlang::quo(x)
  return(out)
}
lobstr::obj_size(wrapped_quosure())
lobstr::obj_size(butcher(wrapped_quosure))

Run the code above in your browser using DataLab