[Esm-commits] r31 - in pkg/ESM: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Aug 28 15:24:58 CEST 2010


Author: timotheepoisot
Date: 2010-08-28 15:24:57 +0200 (Sat, 28 Aug 2010)
New Revision: 31

Modified:
   pkg/ESM/DESCRIPTION
   pkg/ESM/R/functions.r
   pkg/ESM/R/matrix.hr.r
Log:
Added a new graphical function and simplified several others

Modified: pkg/ESM/DESCRIPTION
===================================================================
--- pkg/ESM/DESCRIPTION	2010-08-28 11:02:05 UTC (rev 30)
+++ pkg/ESM/DESCRIPTION	2010-08-28 13:24:57 UTC (rev 31)
@@ -1,6 +1,6 @@
 Package: ESM
-Version: 1.1.0-05
-Date: 2010-04-27
+Version: 1.2.0-05
+Date: 2010-08-28
 Title: Ecological Specificity Measures
 Author: Timothee Poisot <tpoisot at um2.fr>
 Maintainer: Timothee Poisot <tpoisot at um2.fr>

Modified: pkg/ESM/R/functions.r
===================================================================
--- pkg/ESM/R/functions.r	2010-08-28 11:02:05 UTC (rev 30)
+++ pkg/ESM/R/functions.r	2010-08-28 13:24:57 UTC (rev 31)
@@ -15,11 +15,12 @@
 	return(1-(Ni-1)/(N-1))
 }
 
-get.HS <- function(pop)
+get.HS <- function(pop,ifzero=1e-12)
 {
 	if(length(pop)==1){return(1)}
 	partiel <- NULL
-	pop <- as.vector(pop)+0.000000000001
+	pop <- as.vector(pop)
+	pop[pop==0] <- ifzero
 	for(i in 1:length(pop))
 	{
 		p <- pop[i]/sum(pop)
@@ -40,7 +41,7 @@
 	return(SSI)
 }
 
-PDI <- function(m)
+pdi <- function(m)
 {
 	spe <- vector('numeric',length=nrow(m))
 	for(i in 1:nrow(m))
@@ -80,10 +81,10 @@
 	return(spe)
 }
 
-getspe <- function(mat,measure=PDI)
+getspe <- function(mat,measure=pdi,...)
 {
 	if(max(mat)!=1){mat<-mat/max(mat)}
-	out <- measure(as.matrix(mat))
+	out <- measure(as.matrix(mat),...)
 	names(out) <- rownames(mat)
 	return(out)
 }

Modified: pkg/ESM/R/matrix.hr.r
===================================================================
--- pkg/ESM/R/matrix.hr.r	2010-08-28 11:02:05 UTC (rev 30)
+++ pkg/ESM/R/matrix.hr.r	2010-08-28 13:24:57 UTC (rev 31)
@@ -1,11 +1 @@
-matrix.hr <- function(matrix)
-{
-	for(c in 1:ncol(matrix))
-	{
-		for(r in 1:nrow(matrix))
-		{
-			if(matrix[r,c]>0){matrix[r,c]<-1}
-		}
-	}
-	return(matrix)
-}
\ No newline at end of file
+qtobin <- function(matrix){return(matrix[matrix>0]<-1)}
\ No newline at end of file



More information about the Esm-commits mailing list