attach
Attach a Set of Objects to the Search Path

Description

Creates an environment from a data frame, a named list, or a file, and then adds it to the search path.

Usage

attach(what, pos = 2, name = deparse(substitute(what)), 
   warn.conflicts = TRUE)

Arguments

what a named list, data frame, environment, or file containing the list of objects and functions.
pos an integer value representing the position of the package to be attached in the search list.
name a character string indicating the name of the environment displayed in the search list.
  • If what is a list, and the name is not specified, the name of what is taken.
  • If what is a file name, "file:" is prefixed to the file name in what and the name argument is ignored.
warn.conflicts a logical value. If TRUE (the default), gives warning messages if the new objects conflict with the objects in the attached packages.
Value
returns an invisible environment with a name attribute, which is newly created after attaching to the search list.
See Also
detach, objects.
Examples
x <- data.frame(Name=c("Joe","Bill"), Age=c(29,41))
attach(as.data.frame(x), name="MyData") # attach a data frame 

# Now the columns are available: Name # [1] Joe Bill # Levels: Bill Joe exists("Age") # TRUE

search()

tmpsave <- tempfile("save") save(list=names(x), file=tmpsave) detach(2) # Now the columns are no longer available: exists("Age") # FALSE

attach(tmpsave) Age # [1] 29 41

detach(2)

unlink(tmpsave) # clean up

Package base version 6.1.4-13
Package Index