[R] attach
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Sat Oct 17 10:11:43 CEST 2009
Dieter Menne wrote:
>
>
> Christophe Dutang1 wrote:
>>
>> I would like to know what happens on the memory side when I use
>> attach(inputdata)
>>
>> Is there a second allocation of memory for inputdata?
>>
>
> Not, it just guides the syntax.
Wrong. There's a virtual copy of data plus a conversion from data frame
to attached environment on the search path. If you modify data in either
of the original frame or the environment, you will get duplication.
>
> Christophe Dutang1 wrote:
>> Is it better not to use attach function?
>>
>
> A qualified "yes" in the sense of "do not use it". I think it is used to
> much in old documentation, presumably because some S eggshells.
>
> I use with() if I have a nasty formula to unclutter; it acts locally only
> and you don't get unwanted side effects.
Well, opinions vary. Having to qualify data frame access on each use
does tend to get in the way of explorative work, at least it does so for
me.
--
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list