#Actinia equina anemone distributions #Set working directory to where data file is located #or enter path to the data file data<-read.csv("ActiniaXYdata.csv",header=TRUE) data$X<-round(data$X,1); data$Y<-round(data$Y,1) # round(data,1) pdd<-c(4.9,1.3,5.3,1.6,3.9,3.8,1.8,3.5,3,2.9,3,3.9,3,3.3,2.1,4.5,3.2,4.2,6.1,3.8,4,4,3.8,1.5,3.9,4.3,4.1,3.9,1.8,3.2,4.2,3.2,1.9,4,2,3.8,1.5,5.9,3.9,4.1,3,3.6,3.2,3.8,3.9,2.5,5.5,3,1.5,3.9,2.5,4,1.2,4,3.9,3.7,1.8,4.4,3.2,3.9,3.7,3.7,4.4,3.9,4.6,4.2,5,4,4.6,5,3.7,3,4.1,1.5,4,3.2,3,1.7,4,3,3.1,3.8,4.2,5,2,4,4.1,3.9,3.1,3,1.6,3.7,3.5,3,3.8,3.9,4,4.9) plot(data, pch=19, xlim=c(0,50),ylim=c(0,50),col="darkred", cex=pdd/1.6, xlab="X coordinate (cm)", ylab="Y coordinate (cm)") #cex is adjusted to scale diameter of anemones rect(0,0,50,50,lty=4,lwd=0.6) hypotenuse<-function(x1,y1,x2,y2) sqrt((x1-x2)^2 +(y1-y2)^2) N<-nrow(data) distances<-matrix(nrow=N,ncol=N) #the cells of the matrix are automatically filled with NAs if nothing is specified for (i in 1:N){ for(j in 1:N){ distances[i,j]<-hypotenuse(data$X[i],data$Y[i],data$X[j],data$Y[j]) }} NNDs<-NULL for (i in 1:N) NNDs<-c(NNDs, min(distances[i,which(distances[i,]>0)])) hist(NNDs,col="pink") RE<-1/(2*sqrt(0.0392)) R<-mean(NNDs)/RE t.test(NNDs, mu=RE) plot(sort(NNDs)^2,-log(1-((1:N)/(N+1))),ylab="Weiss Index",xlab="NND^2",pch=18,main="Weiss plot of anemone spacing") lines(sort(NNDs)^2,-log(1-((1:N)/(N+1))),col="red")