[R] To improve my understanding of workspaces

Thomas Lumley tlumley at u.washington.edu
Fri Mar 10 19:26:42 CET 2006


On Fri, 10 Mar 2006, Adaikalavan Ramasamy wrote:
>
> The attach function appears to have two functions now :

Since R 1.1.0, in fact.

> a) attach("lala.rda") loads objects from lala.rda into the search path
> b) attach(obj) makes the named columns of a dataframe or list available
> in the search path. Therefore you only need to type 'aaa' instead of
> obj$aaa or obj[ , "aaa"]
>
> The second is the more popular form of usage.
>
> Personally I would rather not use attach() and prefer to type obj$aaa or
> use in the context of lm( aaa ~ ., data=obj ).

This distinction is relevant only to the second syntax for attach. 
Attaching an .rda file is more like loading a package -- it makes the 
whole object available, and is very similar to attach() in S-PLUS.

 	-thomas




More information about the R-help mailing list