Hi,

Without a reproducible example (providing data with dput(), please)
it's hard to say for certain, but my suspicion is that this is a R FAQ
7.31 issue.

Sarah

On Mon, Mar 10, 2014 at 11:26 AM, Cesar Caballero <c.caball...@bcbl.eu> wrote:
> 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
>


-- 
Sarah Goslee
http://www.functionaldiversity.org

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

Reply via email to