# 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(2,2))
plot(X, main="Original pattern, Point Type")
X$marks <- data.frame(PointWeight=X$marks$PointWeight, PointType=X$marks$PointType)
plot(X, main="Original pattern, Point Weight")
# Randomize it
Y <- RandomLabeling.M(X)
Z <- Y
# Invert the order of columns in mark to plot the point type, not the point weight
Y$marks <- data.frame(PointType=Y$marks$PointType, PointWeight=Y$marks$PointWeight)
# Labels have been redistributed randomly accross locations
plot(Y, main="Randomized pattern, Point Type")
# But weights are unchanged
Y <- Z
plot(Y, main="Randomized pattern, Point Weight")
Run the code above in your browser using DataLab