# Simulate a point pattern with five types
X <- rpoispp(50)
PointType <- sample(c("A", "B", "C", "D", "E"), X$n, replace=TRUE)
PointWeight <- runif(X$n, min=1, max=10)
X$marks <- data.frame(PointType, PointWeight)
par(mfrow=c(1,2))
plot(X, main="Original pattern, Point Type")
# Randomize it
Y <- PopulationIndependence.M(X, "A")
# Invert the order of columns in mark to plot the point type, not the point weight
Y$marks <- data.frame(Y$marks$PointType, Y$marks$PointWeight)
# Points of type "A" (circles) are unchanged,
# all other points have been redistributed randomly accross locations
plot(Y, main="Randomized pattern, Point Type")
Run the code above in your browser using DataLab