From p.dalgaard@biostat.ku.dk  Wed Apr 10 14:59:53 2002
From: p.dalgaard@biostat.ku.dk (Peter Dalgaard BSA)
Date: 10 Apr 2002 15:59:53 +0200
Subject: [Rd] Strange assignment bug (PR#1450)
In-Reply-To: <200204101336.PAA09300@pubhealth.ku.dk>
References: <200204101336.PAA09300@pubhealth.ku.dk>
Message-ID: <x2d6x77ixy.fsf@blueberry.kubism.ku.dk>

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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] Strange assignment bug (PR#1450)
Peter Dalgaard BSA