[Rd] Strange assignment bug (PR#1450)

Peter Dalgaard BSA p.dalgaard@biostat.ku.dk
10 Apr 2002 16:27:00 +0200


G.Innocent@vet.gla.ac.uk writes:

> 6) The above code appears to be the minimum of code required to reproduce
> the results on my machine.

You can do better than that:

> f
function(A) {
  A$p[1] <- 2
  E <- A$p 
  E[1:2] <- 0.1*A$p[2:3]
  return(A)
}
> x
  p
1 0
2 1
3 2
> f(x)
    p
1 0.1
2 0.2
3 2.0

Notice that the last line changing E is effectively changing A$p, so
something is up with our duplication-avoidance scheme. Luke?

-- 
   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-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._