# Example 1: Random values and Spearman's rho (correlation)

extensions [r] turtles-own [weight height] to setup ... ;; create turtles with weight and height randomly chosen from ;; Weibull and Beta distribution crt 40 [ set weight r:get "rweibull(1,1)" set height r:get "rbeta(1,1,1)" ] end to go tick ... ;; create R list from turtles (r:putagent "turtles" turtles "weight" "height") ;; calculate correlation between weight and height r:eval "c <- cor.test(turtles$weight,turtles$height, method = 'spearm', alternative = 'g'" let rho r:get "c$p.value" let p r:get "c$estimate" ... end