set.seed(1)
## Creating a two dimensional space
space <- space.maker(100, 2, distribution = stats::rnorm)
## Generating the four types of reductions
random <- reduce.space(space, "random", remove = 0.5)
size <- reduce.space(space, "size", remove = 0.5)
density <- reduce.space(space, "density", remove = 0.5)
position <- reduce.space(space, "position", remove = 0.5)
evenness <- reduce.space(space, "evenness", remove = 0.5)
## Plotting the four different results
par(mfrow = c(3,2))
plot(space, pch = 19, col = c("grey", "black")[as.factor(random)],
main = "Random removal")
plot(space, pch = 19, col = c("grey", "black")[as.factor(size)],
main = "Size removal")
plot(space, pch = 19, col = c("grey", "black")[as.factor(density)],
main = "Density removal")
plot(space, pch = 19, col = c("grey", "black")[as.factor(position)],
main = "Position removal")
plot(space, pch = 19, col = c("grey", "black")[as.factor(evenness)],
main = "Evenness removal")
## The space reduction with specific parameters:
# Using the point with coordinates (2,2) as the centre
# Running over a maximum of 300 iterations
# With a tolerance of 0.05 (5%)
reduce.space(space, "size", remove = 0.2,
parameters = list("centre" = c(2,2)),
tuning = list("max" = 300, "tol" = 0.05))
## Remove a specific amount to match a specific parameter
reduce.space(space, type = "size", parameters = list("radius" = 1.206866))
Run the code above in your browser using DataLab