Skip to content

nearest neighbours

3 messages · Kátia Emidio, Kingsford Jones

#
Hi Katia --

Are you looking for something like this?:

library(spatstat)
data amacrine
out <- vector(length = 5, mode = 'list')
for (k in 1:5) out[[k]] <- nnwhich(amacrine, k = k)
names(out) <- paste('k =', 1:5)
str(out)
# List of 5
#  $ k = 1: int [1:294] 153 1 161 161 160 154 155 9 8 11 ...
#  $ k = 2: int [1:294] 2 154 12 153 14 7 6 167 156 156 ...
#  $ k = 3: int [1:294] 4 6 159 3 159 3 156 155 167 157 ...
#  $ k = 4: int [1:294] 161 153 4 160 162 2 154 156 169 158 ...
#  $ k = 5: int [1:294] 154 4 154 2 161 155 10 7 157 7 ...

If you wanted to do this within marks you could subset by mark first
-- see ?split.ppp.

You might also find the following search useful:
help.search('nearest', package = 'spatstat')


hth,

Kingsford Jones
On Fri, Sep 25, 2009 at 9:31 AM, K?tia Emidio <kat.emidio at gmail.com> wrote:
#
On Fri, Sep 25, 2009 at 12:07 PM, Kingsford Jones
<kingsfordjones at gmail.com> wrote:

            
of course the above should have been
data(amacrine)