x = rnorm(100)
y = rnorm(100)
dat = cbind(x,y)
tree = createIndex(dat) #default tree type is "quad"
#our rectangle has corners at (0,0), (0,2), (2, 2), and (2,0)
inds = getPointsInRect(tree, c(0, 0), c(2, 2), dat)
#prepare vector of plotting characters
ch = rep(1, times = 100)
ch[inds] = 3
#plot points indicating which ones were selected as in our rectangle
plot(x,y, pch = ch)
#add rectangle to plot
xpts = c(0, 0, 2, 2, 0)
ypts = c(0, 2, 2, 0, 0)
lines(xpts, ypts)
Run the code above in your browser using DataLab