Example 3: Point pattern analysis with NetLogo agents
see an example output here
extensions [r] to setup ... ;; load R package spatstat for spatial statistics r:eval "library(spatstat)" ... end to go ... ;; send agent variables into an R data-frame (r:putagentdf "agentset" turtles "who" "xcor" "ycor") ;; create point pattern with vectors of x- and ;; y-coordinates of turtles and the dimensions ;; of the window/world let revalstring (word "agppp <- ppp(agentset$xcor, agentset$ycor, c(" min-pxcor "," max-pxcor "), c(" min-pycor "," max-pycor "))") r:eval revalstring ;; calculate L function with simulation of goodness-of-fit envelope r:eval "Lsim <- envelope(agppp, Lest)" ;; get results from R let r r:get "Lsim$r" let obs r:get "Lsim$obs" let theo r:get "Lsim$theo" let high r:get "Lsim$hi" let low r:get "Lsim$lo" ... end