On 28/05/2009, at 12:36 PM, Zhou Fang wrote:
Okay, someone explain this behaviour to me:
Browse[1]> replace(rep(0, 4000), temp1[12] , temp2[12])[3925]
[1] 0.4462404
Browse[1]> temp1[12]
[1] 3926
Browse[1]> temp2[12]
[1] 0.4462404
Browse[1]> replace(rep(0, 4000), 3926 , temp2[12])[3925]
[1] 0
For some reason, R seems to shift indices along when doing this
replacement.
Has anyone encountered this bug before? It seems to crop up from time
to time, seemingly at random. Any idea for a fix? Reassigning the
variables seems to preserve the magicness of the numbers. It all seems
very bizarre and worrying.
If anyone is interested in a R workspace to reproduce this, email me.
This is running in R 2.9.
Doesn't happen to me:
> temp1 <- sample(1:10000,20)
> temp2 <- runif(20)
> temp1[12] <- 3926
> temp2[12] <- 0.4462404
> temp1[12]
[1] 3926
> temp2[12]
[1] 0.4462404
> xxx <- replace(rep(0, 4000), temp1[12] , temp2[12])
> xxx[3925]
[1] 0
> xxx[3926]
[1] 0.4462404
OMMMMMMMMMMMMMMMMMM!
cheers,
Rolf Turner
######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.