[Rd] round to even digit (PR#3604)

kbroman at jhsph.edu kbroman at jhsph.edu
Thu Jul 31 20:53:51 MEST 2003


Full_Name: Karl W Broman
Version: 1.7.1
OS: Linux
Submission from: (NULL) (162.129.44.18)


There appears to be a slight problem with round(); for rounding off a 5, 
it should go to the even digit, but there appear to be some cases where
it goes to an odd digit; see below.

Thanks! karl

~[1007]$ R --vanilla

R : Copyright 2003, The R Development Core Team
Version 1.7.1  (2003-06-16)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type `license()' or `licence()' for distribution details.

R is a collaborative project with many contributors.
Type `contributors()' for more information.

Type `demo()' for some demos, `help()' for on-line help, or
`help.start()' for a HTML browser interface to help.
Type `q()' to quit R.

> round(c(0.175, 1.175, 2.175, 3.175, 4.175, 5.175, 6.175, 7.175, 8.175, 9.175),
2)
 [1] 0.18 1.18 2.17 3.17 4.17 5.17 6.17 7.17 8.18 9.18
> round(c(1.75, 11.75, 21.75, 31.75, 41.75, 51.75, 61.75, 71.75, 81.75, 91.75),
1)
 [1]  1.8 11.8 21.8 31.8 41.8 51.8 61.8 71.8 81.8 91.8
> 
> version
         _                
platform i686-pc-linux-gnu
arch     i686             
os       linux-gnu        
system   i686, linux-gnu  
status                    
major    1                
minor    7.1              
year     2003             
month    06               
day      16               
language R                
>



More information about the R-devel mailing list