data(iris)
# Find fixed radius nearest neighbors for each point
nn <- frNN(iris[,-5], eps=.5)
# Number of neighbors
hist(sapply(nn$id, length),
xlab = "k", main="Number of Neighbors",
sub = paste("Neighborhood size eps =", nn$eps))
# Explore neighbors of point i = 10
i <- 10
nn$id[[i]]
nn$dist[[i]]
plot(iris[,-5], col = ifelse(1:nrow(iris) %in% nn$id[[i]], "red", "black"))
Run the code above in your browser using DataLab