The clean_env
function is designed to clean the global
environment of all objects except those specified by type or by name.
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.
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.
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")
}