I have some difficulties applying the inhomogeneous G-function to my point pattern in R
. In order to use GmultiInhom
, I first tried to convert my point pattern bci.tree8pppa
to a multitype pattern:
bci.tree8multi = ppp(bci.tree8pppa$x, bci.tree8pppa$y, window=owin(c(0,1000), c(0,500)), marks = factor(bci.tree8pppa$marks[,3]))
Then applied the G-function as follows:
G = GmultiInhom(bci.tree8multi, marks(bci.tree8multi) == species1, marks(bci.tree8multi) == species2, lambdaI = lambda1points, lambdaJ = lambda2points, lambdamin = min(lambda2points), r = c(0,r1,r2,r3))
But this yields the error: "Error in split.default(X, group): factor has bad level"
How can I solve this? Thank you in advance!
For the benefit of any R
programmers out there: I traced the error message "factor has bad level"
to the C source code for .Internal(split.default(x,f))
in the base R
system. This error message can occur only when f
is a list
rather than a factor
. The code converts f
to a factor using the function interaction
which performs character string manipulations. This conversion can go wrong, in the sense that the resulting factor has "bad levels": the integer representation of the factor includes values less than 1 or greater than the number of levels of the factor. Then the error occurs.
The original post has not provided a working example, so it's difficult to figure out exactly how the code in spatstat::GmultiInhom
caused the wrong type of data to be fed to split.default
. However, it must be related to the misuse of the argument r
. The code in spatstat
will be tightened to enforce stricter requirements on the format of r
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.