Subject: Re: [R] .Alias
From: Peter Dalgaard BSA (p.dalgaard@biostat.ku.dk)
Date: Thu 26 Oct 2000 - 23:33:06 EST
Message-ID: <x2y9zbhgml.fsf@blueberry.kubism.ku.dk>
Jens Oehlschlägel <jens.oehlschlaegel@bbdo-interone.de> writes:
> Not only changing mode or length (i.e. structure) of the original object
> results in converting an .Alias into a real copy, as the following examples
> show:
>
> > x <- 1:9
> > y <- .Alias(x[9])
> > y[1]
> [1] 9
> > y[1] <- 10
> > x
> [1] 1 2 3 4 5 6 7 8 9
> # not [1] 1 2 3 4 5 6 7 8 10 as expected
>
> > x <- 1:9
> > y <- .Alias(x[9])
> > x[9] <- 10
> > y
> [1] 9
> # not [1] 10 as expected
>
> Why is that? Are these read-ony pointer?
You can only .Alias entire R objects, and x[9] is not one, it is an
expression which can be evaluated to an R object and you're
effectively .Aliasing the unnamed result of that evaluation.
-- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@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@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
This archive was generated by hypermail 2b25 : Thu 01 Feb 2001 - 16:14:29 EST