[R] Significant digits for checking values of variable?
David Afshartous
dafshartous at med.miami.edu
Wed Aug 27 17:51:07 CEST 2008
All,
I'm witnessing some strange behavior when checking the values of one of my
variables. My guess is that it has something to do with the number of
significant digits being represented, but perhaps not as my variable was
created from other variables that only had one decimal place. See below.
I'm sure this is something basic, any suggestions much appreciated.
Cheers,
David
> visit.2.SEK.delta.baseline
[1] 0.1 -0.7 0.8 -0.1 -0.5 0.8 0.7 0.2 0.4 0.3 0.6 0.6 0.3 0.8
0.8 0.3 0.4 0.8
> visit.2.SEK.delta.baseline > 0
[1] TRUE FALSE TRUE FALSE FALSE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
TRUE TRUE TRUE TRUE TRUE TRUE
> visit.2.SEK.delta.baseline == .8
[1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
FALSE FALSE FALSE FALSE FALSE FALSE
### but some of the values are equal to .8
## here it is okay when I try to reproduce
> junk = c(0.1, -0.7,0.8, -0.1, -0.5, 0.8, 0.7, 0.2, 0.4, 0.3, 0.6, 0.6,
0.3, 0.8, 0.8, 0.3, 0.4, 0.8 )
> junk == .8
[1] FALSE FALSE TRUE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE
FALSE TRUE TRUE FALSE FALSE TRUE
More information about the R-help
mailing list