[R] (no subject)
BEN at SSANET.COM
Tue Jul 11 21:47:49 CEST 2006
Well, it's a little inelegant, but since the amount of information is
the same in events that are certain to occur and certain not to occur,
you could add the line
prob[prob==0] <- 1
after you set up the prob vector, which would take care of the problem.
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Taka Matzmoto
Sent: Tuesday, July 11, 2006 2:26 PM
To: r-help at stat.math.ethz.ch
Subject: [R] (no subject)
>prob <- c(0.5,0.4,0.3,0.1,0.0)
>cal <- prob * log(prob,base=2)
 -0.5000000 -0.5287712 -0.5210897 -0.3321928 NaN
Is there any way to change NaN to zero ?
R-help at stat.math.ethz.ch mailing list
PLEASE do read the posting guide!
More information about the R-help