detach
Detach Data from the Search List

Description

Remove the package or environment from the search list.

Usage

detach(name, pos = 2, unload = FALSE, character.only = FALSE, 
    force = FALSE) 

Arguments

name a character string or an unquoted name that contains the name of the package or environment in the search list. It can also be an integer, which replaces the argument pos.
pos an integer specifying the package's position in the search list. If name is specified, pos is ignored.
unload a logical value. If the detached package has a namespace, and unload is TRUE, then unloadNamespace is called to unload the package's namespace.
character.only a logical value. If FALSE (the default), name can be an unquoted name or a character string.
force a logical value. If TRUE, the specified package is forced to detach even if other packages depend on it. The default is FALSE.

Details

The package specified with name or pos in the search list is detached, but the package with pos = 1 and the base package cannot be detached. If you try to detach the base package or the package in pos = 1, detach generates an error.
Value
returns invisible NULL.
See Also
attach, assign,
Examples
detach(1)
detach(8) # which represents "package:base"
detach(9) # out of bounds error
detach("abc") 
# Detach the fourth object from the search list.
detach(4) 
detach("package:stats", 6) # name has precedence over pos. 
z <- "package:stats"
detach(z)
# Error in detach(z) : invalid name
x <- list("1", "Joe")
names(x) <- list("SL", "Name")
attach(x)
z <- detach(2)
z
# NULL

Package base version 6.1.1-7
Package Index