[Esm-commits] r43 - in pkg/ESM: . R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Jan 17 22:41:46 CET 2011
Author: timotheepoisot
Date: 2011-01-17 22:41:45 +0100 (Mon, 17 Jan 2011)
New Revision: 43
Modified:
pkg/ESM/DESCRIPTION
pkg/ESM/R/functions.r
Log:
Modified: pkg/ESM/DESCRIPTION
===================================================================
--- pkg/ESM/DESCRIPTION 2011-01-14 16:59:54 UTC (rev 42)
+++ pkg/ESM/DESCRIPTION 2011-01-17 21:41:45 UTC (rev 43)
@@ -1,6 +1,6 @@
Package: ESM
-Version: 2.0.0-01
-Date: 2011-01-14
+Version: 2.0.2-01
+Date: 2011-01-17
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 2011-01-14 16:59:54 UTC (rev 42)
+++ pkg/ESM/R/functions.r 2011-01-17 21:41:45 UTC (rev 43)
@@ -1,5 +1,26 @@
fixmat = function(mat) mat[rowSums(mat)>0,colSums(mat)>0]
+subsamp = function(mat,nc=5,nr=5) fixmat(mat[sample(c(1:nrow(mat)),nr,replace=FALSE),sample(c(1:ncol(mat)),nc,replace=FALSE)])
+entropy = function(vec)
+{
+ uns <- unique(vec)
+ ps <- NULL
+ for(i in 1:length(uns))
+ {
+ ps <- c(ps,sum(vec==uns[i])/length(vec))
+ }
+ ENT = -sum(ps*log(ps))
+ INF = ENT/log(length(uns))
+ return(as.data.frame(list(E=ENT,I=INF)))
+}
+
+simpson = function(fit)
+{
+ fit <- round(fit*1000,0)
+ Simp <- sum(fit*(fit-1))/(sum(fit)*(sum(fit)-1))
+ return(Simp)
+}
+
pdi <- function(fit)
{
if(length(fit)==1){return(1)}
@@ -38,7 +59,7 @@
return(1-shannon)
}
-ssi = function(fit)
+ssi <- function(fit)
{ # Normalized and using quantitative data
if (length(fit) == 1) {
return(1)
More information about the Esm-commits
mailing list