Документ взят из кэша поисковой машины. Адрес оригинального документа : http://herba.msu.ru/shipunov/software/r/infill/infill.r
Дата изменения: Sat May 26 09:35:58 2007
Дата индексирования: Tue Oct 2 05:04:48 2012
Кодировка:
infill<- function(x, n=10, plot=TRUE, cumulative=FALSE) {

sub<-substitute(x)
dep<-deparse(n)

x<-x[,colSums(x)!=0]
mat.rdu <- numeric(0)
x<-as.matrix(x)
x[x>0]<-1
x<-as.data.frame(x)
for (j in 1:n) {
ini.rdu <- rep(0, nrow(x))
sam.rdu <- sample(1:nrow(x), nrow(x))
dat.rdu<-cbind(1:nrow(x),x[sam.rdu,])
for (i in 1:ncol(dat.rdu)){
number.rdu<-dat.rdu[dat.rdu[,i]==1,1][1]
ini.rdu[number.rdu]<-ini.rdu[number.rdu]+1
if(cumulative && (number.rdu!=length(ini.rdu)))
for(k in (number.rdu+1):length(ini.rdu))
ini.rdu[k]<-ini.rdu[k]+1
}
mat.rdu <- cbind(mat.rdu, ini.rdu)
}
n

if(cumulative) {
mat.rdu <- mat.rdu*100/ncol(x)
ylab = "% of all species"
} else ylab = "species"

dimnames(mat.rdu)[[2]] <- 1:n
if (plot) {

mean.mat.rdu <- apply(mat.rdu, 1, mean)
plot(mean.mat.rdu, type="l", ylab=ylab,xlab="sites",
main=paste("Mean filling plot of ", sub, ", ", dep, " permutations", sep=""), axes=F)
axis(1, seq(0, length(mean.mat.rdu), by=1))
axis(2, seq(0, max(mean.mat.rdu)))
box()
}
else return(mat.rdu)
}