#' Function for computing beta diversity within islands or plots
#'
#' @ indat = input data frame
#' @ from = character vector with column number where to start computations from
#' @ group = grouping factor i.e. island or plot or whatever else
#'
betawithin<-function(indat,from,group){
indat<-as.data.frame(indat)
results<-NULL
group.l<-as.character(unique(indat[,group]))
for (i in 1:length(group.l)){
tmp<-indat[indat[,group] %in% group.l[i],]
tmp1<-as.data.frame(tmp)
tmp2<-tmp1[,from:dim(tmp1)[2]]
tmp3<-tmp2[,names(colSums(tmp2)[colSums(tmp2) > 0])]
tmp4<-beta.multi(tmp3,abund=TRUE)
tmp5<-data.frame(group=group.l[i],
comp=row.names(tmp4)[2:3],value=tmp4[2:3,1],hab="All habitats")
results<-rbind(tmp5,results)
}
return(results)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.