# 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)
X <- as.wmppp(X)
autoplot(X, main="Original pattern")
# Randomize it
Y <- rPopulationIndependenceM(X, "A")
# Points of type "A" are unchanged,
# all other points have been redistributed randomly across locations
autoplot(Y, main="Randomized pattern")
Run the code above in your browser using DataLab