rmExcept: ' Remove all objects from a workspace except those specified...

View source: R/utils.R

rmExceptR Documentation

' Remove all objects from a workspace except those specified by the user.

Description

rmExcept removes all objects from a workspace except those specified by the user.

Usage

rmExcept(keepers, envir = globalenv(), message = TRUE)

Arguments

keepers

a character vector of the names of object you would like to keep in your workspace.

envir

the environment to remove objects from. The default is the global environment (i.e. globalenv).

message

logical, whether or not to return a message informing the user of which objects were removed.

Examples

# Create objects
A <- 1; B <- 2; C <- 3

# Remove all objects except for A
rmExcept("A")
ls()

nyu-mhealth/Mobility documentation built on July 4, 2025, 9:54 a.m.