[Rd] Strange assignment bug (PR#1450)
Peter Dalgaard BSA
p.dalgaard@biostat.ku.dk
10 Apr 2002 15:59:53 +0200
G.Innocent@vet.gla.ac.uk writes:
> inter.gp.effect <- 0.1
>
> animals <- data.frame(pos = 0:2)
>
> SI.model <- function(Animal.group) {
>
> group <- 1
> Animal.group$pos[group] <- Animal.group$pos[group] + 1
> effective.animals <- Animal.group$pos # allows us to model inter-group
> contact
> #
> effective.animals[1:(length(Animal.group$pos)-1)] <-
> effective.animals[1:(length(Animal.group$pos)-1)] +
> inter.gp.effect*Animal.group$pos[2:length(Animal.group$pos)]
> ##
> effective.animals[2:length(Animal.group$pos)] <-
> effective.animals[2:length(Animal.group$pos)] +
> inter.gp.effect*Animal.group$pos[1:(length(Animal.group$pos)-1)]
> return(Animal.group)
> }
>
> print(SI.model(animals))
>
> ####################################################
>
> results:
> > source("c:\\r work\\simulation model\\bug.R")
> pos
> 1 1.10
> 2 1.31
> 3 2.12
>
> Expected results:
> pos
> 1 1
> 2 1
> 3 2
Confirmed with 1.5.0pre. I'll have a look.
--
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._