[R] bug?

From: Patrick Jahn <Jahn_at_mathematik.uni-mainz.de>
Date: Thu 27 Jul 2006 - 03:47:06 EST


Dear All,
if you generate a sequence with small latitude like:

x<-seq(0,1,0.005)

and you ask for all points of this lattice how many points are in a neighbourhood with radius 0.01 of each point:

v <- rep( 0 , length( x ) ) ;
for (i in 1:length(x) )

     { v[i] <- length(x[ abs(x-x[i]) < 0.01 ] ) ; };

then the answer should be: v = (2, 3, 3, 3, 3,.......,3, 3, 3, 3, 2), because every point instead of the borders has 3 points in a 0.01-neighbourhood.

but v contains also many 4 and also 5:

> v

  [1] 2 4 3 4 4 3 4 4 3 4 4 3 4 4 4 4 5 4 4 5 4 4 5 4 4 4 3 4 4 4 4 3 3 3 4 4 4
 [38] 4 3 3 4 4 4 4 3 3 4 4 4 4 3 3 3 3 3 3 4 4 4 4 3 3 3 3 3 3 3 3 3 4 4 4 4 3
 [75] 3 3 3 3 3 3 3 3 4 4 4 4 3 3 3 3 3 3 3 3 4 4 4 4 3 3 3 3 3 3 3 3 3 3 3 3 3
[112] 3 3 3 4 4 4 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 3 3 3 3 3
[149] 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
[186] 3 3 3 3 3 4 4 4 4 3 3 3 3 3 3 2

Could anyone explain this fact and help me to compute exactly on general data.

Thank you very much,
Patrick Jahn



R-help@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 and provide commented, minimal, self-contained, reproducible code. Received on Thu Jul 27 03:50:11 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 27 Jul 2006 - 06:16:15 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.