Hi R-users, I am facing a strange behaviour that changes the sign of Inf with a division by zero.
In my script, I have defined the following 3 variables and the elementwise division: > lambda_k[gamma_lambda] # numeric vector [1] -1 0 > del_lambda[gamma_lambda] # numeric vector [1] 0 -1 > gamma_lambda # integer vector with the indexes of the elements in lambda_k & > del_lambda [1] 74 11 > lambda_k[gamma_lambda] / del_lambda[gamma_lambda] [1] Inf 0 The result is surprising instead of -Inf 0 which I would expect because the elementwise division of the elements with index 74 is -1/0. Surprisingly, if I try to do the division with just newly defined numeric vectors with the same values, I obtain the correct result, i.e. > c(-1,0) / c(0,-1) [1] -Inf 0 How can this be explained? Any input would be really welcomed. For your information, I'm using R version 3.0.2 (2013-09-25) and Rstudio Version 0.98.501 on Platform: x86_64-apple-darwin10.8.0 (64-bit). Thanks very much for your help, Cesar ---------------------------------------------------------------------- Cesar Caballero www.bcbl.eu Legal disclaimer/Aviso legal/Lege-oharra: www.bcbl.eu/legal-disclaimer ______________________________________________ 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.