[Ecopd-commits] r94 - in pkg: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Jan 6 00:52:48 CET 2010
Author: regetz
Date: 2010-01-06 00:52:47 +0100 (Wed, 06 Jan 2010)
New Revision: 94
Added:
pkg/R/shannon.R
pkg/man/shannon.Rd
Modified:
pkg/DESCRIPTION
pkg/NAMESPACE
Log:
added function for calculating Shannon diversity index (non-phylo)
Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION 2009-11-18 21:29:58 UTC (rev 93)
+++ pkg/DESCRIPTION 2010-01-05 23:52:47 UTC (rev 94)
@@ -8,6 +8,6 @@
Depends: methods, phylobase
Description: A set of metrics and functions for combining ecological and phylogenetic information
License: GPL
-Collate: phylo4com.R coerce.R genera.R utilities.R community.R pd.R aed.R iac.R pae.R simpson.R indices.R plots.R
+Collate: phylo4com.R coerce.R genera.R utilities.R community.R pd.R aed.R iac.R pae.R shannon.R simpson.R indices.R plots.R
LazyLoad: yes
LazyData: yes
Modified: pkg/NAMESPACE
===================================================================
--- pkg/NAMESPACE 2009-11-18 21:29:58 UTC (rev 93)
+++ pkg/NAMESPACE 2010-01-05 23:52:47 UTC (rev 94)
@@ -15,7 +15,7 @@
# metric methods
exportMethods(pd, pae, iac, ed, eed, hed, aed, eaed, haed, value)
-exportMethods(simpson)
+exportMethods(shannon, simpson)
#----------------------------------------------------------------------
Added: pkg/R/shannon.R
===================================================================
--- pkg/R/shannon.R (rev 0)
+++ pkg/R/shannon.R 2010-01-05 23:52:47 UTC (rev 94)
@@ -0,0 +1,22 @@
+##
+## Shannon's index
+##
+
+setGeneric("shannon",
+ function(x) {
+ standardGeneric("shannon")
+})
+
+setMethod("shannon", signature(x="phylo4d"),
+ function(x) {
+ phyc <- phylo4com(x)
+ shannon(phyc)
+})
+
+setMethod("shannon", signature(x="phylo4com"),
+ function(x) {
+ N.relative <- prop.table(t(abundance(x)), 1)
+ out <- apply(N.relative, 1, function(n) -sum(n * log(n)))
+ return(out)
+})
+
Property changes on: pkg/R/shannon.R
___________________________________________________________________
Name: svn:eol-style
+ native
Added: pkg/man/shannon.Rd
===================================================================
--- pkg/man/shannon.Rd (rev 0)
+++ pkg/man/shannon.Rd 2010-01-05 23:52:47 UTC (rev 94)
@@ -0,0 +1,31 @@
+\name{shannon}
+\docType{methods}
+\alias{shannon}
+\alias{shannon-methods}
+\alias{shannon,phylo4com-method}
+\alias{shannon,phylo4d-method}
+\title{Shannon diversity index}
+\description{
+ Calculates the Shannon diversity index for a set of communities.
+}
+\usage{
+ \S4method{shannon}{phylo4com}(x)
+ \S4method{shannon}{phylo4d}(x)
+}
+\arguments{
+ \item{x}{A \code{phylo4com} or \code{phylo4d} object.}
+}
+\details{
+ TODO
+}
+\value{
+ A numeric vector of length equal to the number of communities.
+}
+\references{
+ TODO
+}
+\author{Jim Regetz (regetz at nceas.ucsb.edu)}
+\examples{
+ shannon(weeds)
+}
+\keyword{methods}
Property changes on: pkg/man/shannon.Rd
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the Ecopd-commits
mailing list