| 1 |
\name{retain} |
| 2 |
\alias{retain} |
| 3 |
\title{Retain Objects in an Environment} |
| 4 |
\description{\code{retain} removes all objects from the environment |
| 5 |
except those mentioned as argument.} |
| 6 |
\usage{ |
| 7 |
retain(\dots, list = character(0), envir = parent.frame(),force=FALSE) |
| 8 |
} |
| 9 |
\arguments{ |
| 10 |
\item{\dots}{names of objects to be retained, as names (unquoted) |
| 11 |
or character strings(quoted).} |
| 12 |
\item{list}{a character vector naming the objects to be retained.} |
| 13 |
\item{envir}{the environment from which the objects are removed |
| 14 |
that are not to be retained.} |
| 15 |
\item{force}{logical value. As a measure of caution, this |
| 16 |
function removes objects only from local environments, |
| 17 |
unless \code{force} equals TRUE. In that case, \code{retain} can |
| 18 |
also be used to clear the global environment, the user's workspace.} |
| 19 |
} |
| 20 |
\examples{ |
| 21 |
local({ |
| 22 |
foreach(x=c(a,b,c,d,e,f,g,h),x<-1) |
| 23 |
cat("Objects before call to 'retain':\n") |
| 24 |
print(ls()) |
| 25 |
retain(a) |
| 26 |
cat("Objects after call to 'retain':\n") |
| 27 |
print(ls()) |
| 28 |
}) |
| 29 |
x <- 1 |
| 30 |
y <- 2 |
| 31 |
retain(x) |
| 32 |
} |
| 33 |
\keyword{manip} |