ppp objects not working with deldir function

136 Views Asked by At

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.

2

There are 2 best solutions below

0
On BEST ANSWER

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.

2
On

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.