[R] newbie questions: attached data.frames and rm()
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Fri Mar 23 23:17:54 CET 2001
Alojz Loui Polic <lpolic at ineural.com> writes:
> Hi
>
> I'm just starting with R-plus and I have noticed
?????
> the following behaviour.
>
> If a data.frame is attached and then removed before
> being detached, the data is still present in the
> path and can accessed. Is this expected behaviour,
> and if so why?
It's designed that way. Whether or not that is a good thing is
debatable - people easily get bitten from attaching a data frame and
modifying it without that affecting the attached version. One upside
is that the argument to attach() can be an arbitrary expression, e.g.
AA <- c(1, 1, 1, 1, 1)
BB <- c(2, 3, 2, 1, 2)
attach(data.frame( AA.data=AA, BB.data=BB)
[It is not a trivial exercise to think up an alternative semantic
model for attached objects. One problem being that modifying an object
in R is more often than not a compute-and-rename operation, so
accessing an object by reference is not possible (although reference
by name is).]
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list