Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

keep

Remove All Objects, Except Those Specified


Description

Remove all objects from the user workspace, except those specified.

Usage

keep(..., list=character(0), all=FALSE, sure=FALSE)

Arguments

...

objects to be kept, specified one by one, quoted or unquoted.

list

character vector of object names to be kept.

all

whether hidden objects (beginning with a .) should be removed, unless explicitly kept.

sure

whether to perform the removal, otherwise return names of objects that would have been removed.

Details

Implemented with safety caps: objects whose name starts with a . are not removed unless all=TRUE, and an explicit sure=TRUE is required to remove anything.

Value

A character vector containing object names, or NULL when sure is TRUE.

Author(s)

Arni Magnusson

See Also

keep is a convenient interface to rm when removing most objects from the user workspace.

Examples

data(women, cars)
keep(cars)
## To remove all objects except cars, run:
## keep(cars, sure=TRUE)

gdata

Various R Programming Tools for Data Manipulation

v2.18.0
GPL-2
Authors
Gregory R. Warnes, Ben Bolker, Gregor Gorjanc, Gabor Grothendieck, Ales Korosec, Thomas Lumley, Don MacQueen, Arni Magnusson, Jim Rogers, and others
Initial release
2017-06-05

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.