This help topic is for R version 1.5.0. For the current version of R, try https://stat.ethz.ch/R-manual/R-patched/library/base/html/detach.html
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 either a data.frame which has been attached or a package which was required previously.

Usage

detach(name, pos = 2)

Arguments

name

The object to detach. Defaults to search()[pos]. This can be a name or a character string but not a character vector.

pos

Index position in search() of database to detach. When name is numeric, pos = name is used.

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).

See Also

attach, library, search, objects.

Examples

require(eda)#package
detach(package:eda)
## could equally well use detach("package:eda")
## but NOT  pkg <- "package:eda"; detach(pkg)
## Instead, use
library(eda)
pkg <- "package:eda"
detach(pos = match(pkg, search()))

library(mva)
detach(2)# `pos' used for `name'

[Package base version 1.5.0 ]