Skip to contents

The clean_env function is designed to clean the global environment of all objects except those specified by type or by name.

Usage

clean_env(keep_types = NULL, keep_objects = NULL)

Arguments

keep_types

A vector of classes. Objects in the global environment of these classes will not be removed. Default is NULL.

keep_objects

A vector of character strings. Objects in the global environment with these names will not be removed. Default is NULL.

Value

NULL. This function is called for its side effect of cleaning the global environment.

Details

This function gets all objects in the global environment, and then removes objects based on the keep_types and keep_objects parameters. Any remaining objects are removed from the global environment.

References

Add any relevant references here.

Examples

if (FALSE) {
# Generate some objects
a <- 1
b <- "hello"
c <- list(1, 2, 3)

# Clean the environment but keep lists and the object named 'a'
clean_env(keep_types = "list", keep_objects = "a")
}