Learn R Programming

DataCombine (version 0.2.21)

rmExcept: 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

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

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

# Show workspace
ls()

Run the code above in your browser using DataLab