Aliases: attach .conflicts.OK
Keywords: data
### ** Examples require(utils) summary(women$height) # refers to variable 'height' in the data frame
Min. 1st Qu. Median Mean 3rd Qu. Max. 58.0 61.5 65.0 65.0 68.5 72.0
attach(women) summary(height) # The same variable now available by name
Min. 1st Qu. Median Mean 3rd Qu. Max. 58.0 61.5 65.0 65.0 68.5 72.0
height <- height*2.54 # Don't do this. It creates a new variable # in the user's workspace find("height")
[1] "women"
summary(height) # The new variable in the workspace
Min. 1st Qu. Median Mean 3rd Qu. Max. 147.3 156.2 165.1 165.1 174.0 182.9
rm(height) summary(height) # The original variable.
Min. 1st Qu. Median Mean 3rd Qu. Max. 58.0 61.5 65.0 65.0 68.5 72.0
height <<- height*25.4 # Change the copy in the attached environment find("height")
[1] "women"
summary(height) # The changed copy
Min. 1st Qu. Median Mean 3rd Qu. Max. 1473 1562 1651 1651 1740 1829
detach("women") summary(women$height) # unchanged
Min. 1st Qu. Median Mean 3rd Qu. Max. 58.0 61.5 65.0 65.0 68.5 72.0
## Not run: ##D ## create an environment on the search path and populate it ##D sys.source("myfuns.R", envir = attach(NULL, name = "myfuns")) ## End(Not run)