0

I read a shapefile using maptools package and then converted to .ppp

hfmd <- readShapeSpatial("NEWMERGE.shp")
hfmd2 <- as(hfmd, 'ppp')

When I typed hfmd2, I received this

Marked planar point pattern: 1092 points`
Mark variables: X, Y, Status, ID` 
window: rectangle = [492623.7, 609905.3] x [444011.4, 645190.4] units`

And when I typed Gcross(hfmd2) to run Cross G function, I received this error

Error in marks.ppp(X, ...) :` 
Sorry, not implemented when the marks are a data frame`

My questions are:

  1. Does Gcross() only work with Multitype Marked planar point pattern object?
  2. How do I convert a .ppp object to a Multitype Marked planar point pattern object?
markalex
  • 8,623
  • 2
  • 7
  • 32
KIM
  • 157
  • 1
  • 1
  • 8

1 Answers1

0

Your current ppp has four different mark values: X, Y, Status, ID. Which one do you want to use for Gcross? For now I will assume it is Status. Then you can replace the data.frame containing the four mark values for each point with a single mark vector like this:

marks(hfmd2) <- marks(hfmd2)$Status

Now you should be able to run Gcross:

Gc <- Gcross(hfmd2)

This will estimate Gcross between the first two types in Status.

Ege Rubak
  • 4,347
  • 1
  • 10
  • 18