## Testing complete spatial randomness (CSR)
#-------------------------------------------
if(require("spatstat.explore", quietly=TRUE)) {
pp <- unmark(spruces)
nsim <- 999
nsim <- 19
# Generate nsim simulations under CSR, calculate L-function for the data and simulations
env <- envelope(pp, fun="Lest", nsim=nsim, savefuns=TRUE, correction="translate")
# The deviation test using the integral deviation measure
res <- deviation_test(env, measure='int')
res
# or
res <- deviation_test(env, r_min=0, r_max=7, measure='int2')
}
Run the code above in your browser using DataLab