It looks like you can pass a vector of neighbourhoods to nndist.
nndist(rpp, k=2:10)
Although you get some warnings, the answers appear to be the same.
all.equal(t(sapply(2:10, function(i) nndist(rpp, k=i))), nndist(rpp, k=2:10))
This might be quite a lot faster, depending on how much work is c
If you take a look at what is happening with Rprof, you will see that
most of the time (96.6%) is being taken in the 'nndist' function, so
if you want to improve your algorithm, can you somehow reduce the
number of time you call it, or find a different approach. So it is a
function of the algorith
2 matches
Mail list logo