Strange behavior of R

前端 未结 2 1824
感情败类
感情败类 2021-01-21 15:52

So, I have the following code in R:

y
a <- -0.1    
test <- (1/((y+as.numeric(!y))*(a-1)))  
test  
test^a  
-0.9090909^a 

Giving me the

2条回答
  •  有刺的猬
    2021-01-21 16:21

    -0.9090909 ^ a is the same as -(0.9090909 ^ a). Notice the parentheses.

    However, your test contains negative values, and you cannot take the root of a negative number. Try (-0.9090909) ^ a to verify this:

    > (-0.9090909) ^ -0.1
    [1] NaN
    

提交回复
热议问题