detach {base} | R Documentation |
Detach Objects from the Search Path
Description
Detach a database, i.e., remove it from the search()
path
of available R objects. Usually, this is either a data.frame
which has been attach
ed or a package which was required
previously.
Usage
detach(name, pos = 2, version)
Arguments
name |
The object to detach. Defaults to |
pos |
Index position in |
version |
A character string denoting a version number of the package to be loaded. If no version is given, a suitable default is chosen. |
Value
The attached database is returned invisibly, either as
data.frame
or as list
.
Note
You cannot detach either the workspace (position 1) or the base package (the last item in the search list).
References
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth \& Brooks/Cole.
See Also
attach
, library
, search
,
objects
.
Examples
require(splines)#package
detach(package:splines)
## could equally well use detach("package:splines")
## but NOT pkg <- "package:splines"; detach(pkg)
## Instead, use
library(splines)
pkg <- "package:splines"
detach(pos = match(pkg, search()))
## careful: do not do this unless 'splines' is not already loaded.
library(splines)
detach(2)# 'pos' used for 'name'