[R-sig-eco] rarefy problem (vegan)

Albert Barberán Torrents abarberan at ceab.csic.es
Tue Oct 27 11:42:01 CET 2009


Hi all,
I have been using the rarefy function of vegan but it looks that  
something's wrong with my dataset. The first dataframe (func) works  
perfectly:
 > pdf("commAT_rare_func.pdf")
 > par(mfrow=c(3,3))
 > for (i in 1:9) {	
+ 	N<-colSums(func[i,])
+ 	sub<-c(seq(0,sum(N), by=500), sum(N))
+ 	rar<-rarefy(N, sample=sub, se=T, MARG=2)
+ 	plot(sub, rar[1,], ylab="Richness", xlab="Number of individuals",  
main=row.names(func[i,]), type="l", lwd=3)
+ 	lines(sub, rar[1,]+rar[2,], lty=3)
+ 	lines(sub, rar[1,]-rar[2,], lty=3)
+ 	}
 > dev.off()
but the second one (clust, which is bigger but exactly the same  
structure):
 > pdf("commAT_rare_clust.pdf")
 > par(mfrow=c(3,3))
 > for (i in 1:9) {	
+ 	N<-colSums(clust[i,])
+ 	sub<-c(seq(0,sum(N), by=500), sum(N))
+ 	rar<-rarefy(N, sample=sub, se=T, MARG=2)
+ 	plot(sub, rar[1,], ylab="Richness", xlab="Number of individuals",  
main=row.names(clust[i,]), type="l", lwd=3)
+ 	lines(sub, rar[1,]+rar[2,], lty=3)
+ 	lines(sub, rar[1,]-rar[2,], lty=3)
+ 	}
Error in outer(x, x, "+") : negative length vectors are not allowed
Calls: rarefy -> sapply -> lapply -> FUN -> apply -> FUN -> outer
Execution halted
I don not know what is happening because I calculated other diversity  
metrics with both datasets and it worked fine. Any ideas?
_________________________________
Albert Barberan

CEAB-CSIC
Acces Cala St. Francesc, 14
17300 Blanes, SPAIN
Tel +34 972 33 6101 Fax +34 972 33 7806
http://nodens.ceab.csic.es/ecogenomics
e-mail abarberan at ceab.csic.es



More information about the R-sig-ecology mailing list