# Simulate a point pattern with three types
X <- rpoispp(50)
PointType <- sample(c("A", "B", "C"), X$n, replace=TRUE)
PointWeight <- runif(X$n, min=1, max=10)
X$marks <- data.frame(PointType, PointWeight)
X <- as.wmppp(X)
# Plot the point pattern, using PointType as marks
autoplot(X, main="Original pattern")
# Randomize it
Y <- rPopulationIndependenceK(X, "A", "B")
# Points of type "A" are unchanged, points of type "B" have been moved altogether
# Other points are lost and point weights are set to 1
autoplot(Y, main="Randomized pattern")
Run the code above in your browser using DataLab