[R] Significant digits for checking values of variable?
jim holtman
jholtman at gmail.com
Wed Aug 27 17:47:11 CEST 2008
FAQ 7.31
On Wed, Aug 27, 2008 at 11:51 AM, David Afshartous
<dafshartous at med.miami.edu> wrote:
>
> 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
>
> ______________________________________________
> R-help at 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.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem that you are trying to solve?
More information about the R-help
mailing list