[Esm-commits] r21 - in pkg/ESM: . R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Dec 12 19:14:29 CET 2009
Author: timotheepoisot
Date: 2009-12-12 19:14:29 +0100 (Sat, 12 Dec 2009)
New Revision: 21
Modified:
pkg/ESM/DESCRIPTION
pkg/ESM/R/functions.r
Log:
Modified: pkg/ESM/DESCRIPTION
===================================================================
--- pkg/ESM/DESCRIPTION 2009-11-18 12:42:43 UTC (rev 20)
+++ pkg/ESM/DESCRIPTION 2009-12-12 18:14:29 UTC (rev 21)
@@ -1,11 +1,11 @@
Package: ESM
-Version: 0.1.1-05
+Version: 0.1.2-01
Date: 2009-11-06
Title: Ecological Specificity Measures
-Author: Timothee Poisot <timothee.poisot at univ-montp2.fr>, Michael E Hochberg <michael.hochberg at univ-montp2.fr>
-Maintainer: Timothee Poisot <timothee.poisot at univ-montp2.fr>
+Author: Timothee Poisot <tpoisot at um2.fr>
+Maintainer: Timothee Poisot <tpoisot at um2.fr>
Depends: R (>= 2.1.0)
Suggests: vegan
Description: Performs several measures of ecological specificity
License: GPL (>= 2)
-URL: http://homepage.mac.com/tim.poisot
\ No newline at end of file
+URL: http://www.timotheepoisot.fr
\ No newline at end of file
Modified: pkg/ESM/R/functions.r
===================================================================
--- pkg/ESM/R/functions.r 2009-11-18 12:42:43 UTC (rev 20)
+++ pkg/ESM/R/functions.r 2009-12-12 18:14:29 UTC (rev 21)
@@ -1,3 +1,11 @@
+get.DBF <- function(fit)
+{
+ fit <- sort(as.vector(fit),decreasing=TRUE)
+ test <- fit[2:length(fit)]
+ out <- sum(fit[1]-test)/length(test)
+ return(out)
+}
+
get.HR <- function(pop)
{
Ni <- sum(pop>0)
@@ -5,10 +13,10 @@
return(1-Ni/N)
}
-get.SHANNON <- function(pop)
+get.HS <- function(pop)
{
partiel <- NULL
- pop <- as.vector(pop)+0.0000000001
+ pop <- as.vector(pop)+0.000000000001
for(i in 1:length(pop))
{
p <- pop[i]/sum(pop)
@@ -18,35 +26,6 @@
return(1-shannon)
}
-get.DFP <- function(fit)
-{
- score <- NULL
- fit <- as.vector(fit)
- fit <- na.exclude(sort(fit,decreasing=TRUE))
- vecdiff <- NULL
- for(i in 1:(length(fit)-1))
- {
- vecdiff[i] <- (fit[i+1]-fit[i])+1
- }
- score <- prod(abs(vecdiff))
- return(1-score)
-}
-
-get.WADFP <- function(fit)
-{
- ngen <- length(fit)
- sorted <- sort(fit,decreasing=TRUE)
- tempS <- NULL
- correc <- (ngen-1)/ngen
- for(g in 1:(ngen-1))
- {
- tempS[g] <- (1+sorted[g]-sorted[g+1])*sorted[g]
- }
- S <- sum(tempS)/sum(fit)
- S <- (S-correc)/(2-correc)
- return(S)
-}
-
get.SSI <- function(occup)
{
score <- NULL
@@ -57,37 +36,26 @@
return(SSI)
}
-dfp <- function(m)
+dbf <- function(m)
{
spe <- vector('numeric',length=nrow(m))
for(i in 1:nrow(m))
{
- spe[i] <- get.DFP(m[i,])
+ spe[i] <- get.DBF(m[i,])
}
return(spe)
}
-wadfp <- function(m)
+hs <- function(m)
{
spe <- vector('numeric',length=nrow(m))
for(i in 1:nrow(m))
{
- spe[i] <- get.WADFP(m[i,])
+ spe[i] <- get.HS(as.vector(as.numeric(m[i,])))
}
return(spe)
}
-
-shannon <- function(m)
-{
- spe <- vector('numeric',length=nrow(m))
- for(i in 1:nrow(m))
- {
- spe[i] <- get.SHANNON(as.vector(as.numeric(m[i,])))
- }
- return(spe)
-}
-
ssi <- function(m)
{
spe <- vector('numeric',length=nrow(m))
@@ -114,4 +82,7 @@
out <- measure(as.matrix(mat))
names(out) <- rownames(mat)
return(out)
-}
\ No newline at end of file
+}
+
+cv = function(d) sd(d)/mean(d)
+last = function(d) d[length(d)]
\ No newline at end of file
More information about the Esm-commits
mailing list