[R] .Alias

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Thu Oct 26 15:33:06 CEST 2000


Jens Oehlschlägel <jens.oehlschlaegel at 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 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