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

retain

Retain Objects in an Environment


Description

retain removes all objects from the environment except those mentioned as argument.

Usage

retain(..., list = character(0), envir = parent.frame(),force=FALSE)

Arguments

...

names of objects to be retained, as names (unquoted) or character strings(quoted).

list

a character vector naming the objects to be retained.

envir

the environment from which the objects are removed that are not to be retained.

force

logical value. As a measure of caution, this function removes objects only from local environments, unless force equals TRUE. In that case, retain can also be used to clear the global environment, the user's workspace.

Examples

local({
  foreach(x=c(a,b,c,d,e,f,g,h),x<-1)
  cat("Objects before call to 'retain':\n")
  print(ls())
  retain(a)
  cat("Objects after call to 'retain':\n")
  print(ls())
})
x <- 1
y <- 2
retain(x)

memisc

Management of Survey Data and Presentation of Analysis Results

v0.99.27.3
GPL-2
Authors
Martin Elff (with contributions from Christopher N. Lawrence, Dave Atkins, Jason W. Morgan, Achim Zeileis)
Initial release
2020-11-18

We don't support your browser anymore

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