[R] match() & seq()

Liaw, Andy andy_liaw at merck.com
Mon Jan 30 15:27:16 CET 2006


Hope this is clear:

> x <- seq(0.1, 1, by=0.1)
> 0.3 == x[3]
[1] FALSE
> abs(0.3 - x[3])
[1] 5.551115e-17


Andy

From: Jacques VESLOT
> 
> sorry if it has already been discussed but i can't understand this:
> 
>  > seq(0.1,1,by=0.1)
>  [1] 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
>  > match(0.1,seq(0.1,1,by=0.1))
> [1] 1
>  > match(0.2,seq(0.1,1,by=0.1))
> [1] 2
>  > match(0.3,seq(0.1,1,by=0.1))
> [1] NA
>  > match(0.4,seq(0.1,1,by=0.1))
> [1] 4
> 
>  > R.version
>          _             
> platform i386-pc-mingw32
> arch     i386          
> os       mingw32       
> system   i386, mingw32 
> status                 
> major    2             
> minor    2.1           
> year     2005          
> month    12            
> day      20            
> svn rev  36812         
> language R
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
>




More information about the R-help mailing list