Topic: Species Area

Topic Description:

Functions for calculating species-area curves based on square or rectangular quadrats, using standard R Analytical Tables.



File: speciesarea/spparea.r

View File Source Download File No help file available

Function: selectrandomquad3

Function Description: selectrandomquad3

Creates randomly drawn quadrats, using same arguments and producing same return value as selectrandomquad, but using a different algorithm. The lower left x, y coordinates are drawn at random from a range extending outside the plot dimensions, then quadrats are used only if all 4 corners fall inside the plot.

Function Arguments:

ArgumentDefault Value
size
shape
rep
plotdimc(1000,500)
graphitFALSE

Function Source:

selectrandomquad3=function(size,shape,rep,plotdim=c(1000,500),graphit=FALSE)
{
noquad=length(size)
allsize.x=rep(size,each=rep)
allsize.y=rep(size*shape,each=rep)
total=length(allsize.x)

xlo=runif(total,min=0-2*allsize.x,max=plotdim[1]+2*allsize.x)
ylo=runif(total,min=0-2*allsize.y,max=plotdim[2]+2*allsize.y)
xhi=xlo+allsize.x
yhi=ylo+allsize.y

coord=c(0,0,plotdim[1],plotdim[2])
good.lowerleft=are.ptsinside(pts=data.frame(xlo,ylo),coord=coord)
good.upperleft=are.ptsinside(pts=data.frame(xlo,yhi),coord=coord)
good.upperright=are.ptsinside(pts=data.frame(xhi,ylo),coord=coord)
good.lowerright=are.ptsinside(pts=data.frame(xhi,yhi),coord=coord)
good = good.lowerleft & good.upperleft & good.upperright & good.lowerright

result=data.frame(xlo,ylo,xhi,yhi)
if(graphit) graph.quadrats(result,plotdim=plotdim+2*size)

result=data.frame(xlo,ylo,xhi,yhi)[good,]
if(graphit) graph.quadrats(result[good,],clr="red",add=TRUE)

return(data.frame(xlo,ylo,xhi,yhi,area=(allsize.x*allsize.y)/1e4)[good,])
}