Java Mailing List Archive

http://www.r-help.com/

Home » Home (12/2007) » R Help for Statistical Computing »

[R] round() - strange results

Dongseok Choi

2005-02-22

Replies:

Hello,

I found that round() does not behave as I expected.
Have you had similar experience as following?

> x<-seq(0.5,10.5,by=1)
> x
[1] 0.5 1.5 2.5 3.5 4.5 5.5 6.5 7.5 8.5 9.5 10.5
> round(x)
[1] 0 2 2 4 4 6 6 8 8 10 10
> cbind(x,round(x))
     x  
[1,] 0.5 0
[2,] 1.5 2
[3,] 2.5 2
[4,] 3.5 4
[5,] 4.5 4
[6,] 5.5 6
[7,] 6.5 6
[8,] 7.5 8
[9,] 8.5 8
[10,] 9.5 10
[11,] 10.5 10


Is this a well-known bug?

Thanks in advance,


Dongseok Choi, Ph.D.
Assistant Professor
Division of Biostatistics
Department of Public Health & Preventive Medicine
Oregon Health & Science University
3181 SW Sam Jackson Park Road, CB-669
Portland, OR 97239-3098
TEL) 503-494-5336
FAX) 503-494-4981
choid@(protected)

 [[alternative HTML version deleted]]

______________________________________________
R-help@(protected)
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
©2008 r-help.com - Jax Systems, LLC, U.S.A.