0

I am attempting to use deldir with a ppp object, but receive the following error:

Error: $ operator is invalid for atomic vectors

This does not work:

library(deldir)
library(spatstat)
points <- ppp(x=c(-77.308703, -77.256582, -77.290600,  -77.135668, -77.097144),
              y=c(39.288603, 39.147019, 39.372818, 39.401898, 39.689203),
              window=owin(xrange=c(-77.7,-77), yrange=c(39.1, 39.7)))
deldir(points)

But this works fine:

deldir(x=c(-77.308703, -77.256582, -77.290600,  -77.135668, -77.097144),
       y=c(39.288603, 39.147019, 39.372818, 39.401898, 39.689203),
       rw=c(-77.7, -77, 39.1, 39.7))

Using version 1.0-5 of deldir, version 2.2-0 of spatstat, and version 4.03 of R. I believe the above code worked in previous versions, but I am not sure where the issue is coming from.

Bryan
  • 1,771
  • 4
  • 17
  • 30

2 Answers2

1

This is a bug. It has been corrected by the author of deldir, in version 1.0-6 of the package, which has just been sent to CRAN.

Adrian Baddeley
  • 2,534
  • 1
  • 5
  • 8
0

spatstat has its own interface to deldir since spatstat objects cannot be used directly by deldir as you have experienced. Try dirichlet(points)

Edit: Tge answer above was written from memory on my phone (as is this). It is correct that the usual way to use deldir from spatstat is via spatstat's own interface functions, but it should be possible to invoke deldir directly on a ppp object and it was a bug that this wasn't possible. As @adrian-baddeley says this has been fixed in the new version of deldir.

Ege Rubak
  • 4,347
  • 1
  • 10
  • 18
  • Thanks @Ege, the manual for deldir indicates it should be possible:, i.e.: "Argument x may be a numeric vector or it may be ... an object of class "ppp"." Is that no longer the case? The reason I am trying to use deldir directly is that it outputs `dirsgs` which is directly needed for this use case, and which seemed to work in the past: https://stackoverflow.com/questions/24317733/table-of-shared-edges-for-a-voronoi-tesslleation Is that functionality now available in `spatstat` with the `dirichletNetwork()` function? – Bryan Oct 22 '21 at 08:59
  • I should have written `dirichletEdges()` in the comment above rather than `dirichletNetwork()`. However, I have still not found a way to replicate the `deldir` output, as deldir's `dirsgs` includes the end coordinates of each edge along with the ids of the two points associated with the edge, whereas `dirichletEdges()` only outputs the edge ends. – Bryan Oct 22 '21 at 10:14