Learn R Programming

SciencesPo (version 1.3.9)

clear: Clear Memory of All Objects

Description

This function is a wrapper for the command rm(list=ls()).

Usage

clear(obj = NULL, keep = TRUE)

Arguments

obj
The object (as a string) that needs to be removed (or kept)
keep
Should obj be kept (i.e., everything but obj removed)? Or dropped?

Examples

Run this code
# create objects
a=1; b=2; c=3; d=4; e=5
# remove d
clear("d", keep=FALSE)
ls()
# remove all but a and b
clear(c("a", "b"), keep=TRUE)
ls()

Run the code above in your browser using DataLab