I am conducting linearK function for the observed point pattern on a linear network and I get the following error
Error in retainedges[dat$seg] : invalid subscript type 'list'
I do not understand what it means and how should I correct it.
On the traceback call, I get the following information
> traceback()
4: thinNetwork(x, retainvertices = subi)
3: countends(L, X[-j], D[-j, j], toler = toler)
2: linearKengine(X, r = r, ..., denom = denom, correction = correction,
ratio = ratio)
1: linearK(sl2)
Could someone help me on what this error means and how I can correct it.
Thank you.
Your network is a bit problematic since it is disconnected. It has one very big component with 3755 vertices and 5593 lines and then 5 small components with only 2 or 3 vertices and 1 or 2 lines that are not connected to anything else. In your example you have only two points in this big network (both occurring in the big component as far as I can tell). We might be able to handle this in future versions of
spatstat
, but for now I suggest you simply discard the small empty components. Then I thinklinearK
works as expected for your example (although I doubt you find interesting information from a pattern of 2 points!).To identify connected components of a linear network use
connected.linnet
with argumentwhat = "components"
then you get a list of connected components and you can use the big connected component to define a newlpp
on a connectedlinnet
. With your example you could do something like (noting that component number 1 is the main component):