[Vegan-commits] r2077 - in pkg/vegan: R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Feb 9 17:25:03 CET 2012
Author: jarioksa
Date: 2012-02-09 17:25:02 +0100 (Thu, 09 Feb 2012)
New Revision: 2077
Added:
pkg/vegan/R/simper.R
pkg/vegan/man/simper.Rd
Modified:
pkg/vegan/inst/ChangeLog
Log:
added simper() for similarity percentages; code by Eduard Sz?\195?\182cz
Added: pkg/vegan/R/simper.R
===================================================================
--- pkg/vegan/R/simper.R (rev 0)
+++ pkg/vegan/R/simper.R 2012-02-09 16:25:02 UTC (rev 2077)
@@ -0,0 +1,66 @@
+#' Similarity Percentages
+#'
+#' Discriminating species between two groups using Bray-Curtis dissimilarities.
+#'
+#' @param comm Community data
+#' @param group Vector assigning the groups
+#'
+#' @return
+#' A list of dataframes for every factor-combination.
+#' \item{contr}{average contribution to overall dissimilarity}
+#' \item{sd}{standard deviation of contribution}
+#' \item{contr/sd}{mean to sd ratio}
+#' \item{av_}{average abundance per group}
+#' \item{cum}{cumulative per cent contribution}
+#'
+#' @author Eduard Szöcs \email{szoe8822@@uni-landau.de}
+#' @references Clarke, K.R. 1993. Non-parametric multivariate analyses of changes in community structure. \emph{Austral Ecology}, 18, 117–143.
+#' @export
+#'
+#' @keywords multivariate
+#'
+#' @examples
+#' require(vegan)
+#' data(dune)
+#' data(dune.env)
+#' with(dune.env, simper(dune, Management))
+
+simper <- function(comm, group)
+{
+ comp <- t(combn(unique(as.character(group)), 2))
+ outlist <- NULL
+ for (i in 1:nrow(comp)) {
+ group.a <- as.matrix(comm[group == comp[i, 1], ])
+ group.b <- as.matrix(comm[group == comp[i, 2], ])
+ n.a <- nrow(group.a)
+ n.b <- nrow(group.b)
+ P <- ncol(comm)
+ me <- matrix(ncol = P)
+ md <- matrix(ncol = P)
+ contr <- matrix(ncol = P, nrow = n.a * n.b)
+ for(j in 1:n.b) {
+ for(k in 1:n.a) {
+ for(s in 1:P) {
+ md[s] <- abs(group.a[k, s] - group.b[j, s])
+ me[s] <- group.a[k, s] + group.b[j, s]
+ a <- rowSums(me)
+ c <- md / a
+ contr[(j-1)*n.a+k, ] <- md / a
+ }
+ }
+ }
+ av.contr <- apply(contr, 2, mean) * 100
+ ov.av.dis <- sum(av.contr)
+ sdi <- apply(contr, 2, sd)
+ sdi.av <- sdi / av.contr
+ av.a <- colMeans(group.a)
+ av.b <- colMeans(group.b)
+ dat <- data.frame(av.contr, sdi, sdi.av, av.a, av.b)
+ dat <- dat[order(dat$av.contr, decreasing = TRUE), ]
+ cum <- cumsum(dat$av.contr / ov.av.dis) * 100
+ out <- data.frame(dat, cum)
+ names(out) <- c("contr", "sd", "contr/sd", paste("av_", comp[i, 1], sep = ""), paste("av_", comp[i, 2], sep = ""), "cum")
+ outlist[[paste(comp[i,1], "_", comp[i,2], sep = "")]] <- out
+ }
+ outlist
+}
Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog 2012-02-09 12:46:33 UTC (rev 2076)
+++ pkg/vegan/inst/ChangeLog 2012-02-09 16:25:02 UTC (rev 2077)
@@ -4,11 +4,11 @@
Version 2.1-11 (opened February 5, 2012)
- * indpower: now can handle input objects without dimnames.
- This caused problems with oecosimu, because nullmodel
- objects have no dimnames to save memory.
- Extended example on indpower help page shows the p-value
- and heterogeneity calculations suggested in Halme et al. 2009.
+ * indpower: now can handle input objects without dimnames. This
+ caused problems with oecosimu, because nullmodel objects have no
+ dimnames to save memory. Extended example on indpower help page
+ shows the p-value and heterogeneity calculations suggested in
+ Halme et al. 2009.
* adonis, anosim, mantel, mantel.partial, mrpp, permutest.cca: do
not need clusterEvalQ(parallel, library(vegan)) for socket
@@ -41,6 +41,10 @@
* renyi.Rd: fixed a broken link reported by Arne Erpenbach (Uni
Frankfurt, Germany).
+
+ * simper: new function to implement "similarity percentages" of
+ Clarke (Austral Ecology 18, 117-143; 1993) contributed by Eduard
+ Szöcz (Uni Landau, Germany).
Version 2.1-10 (closed February 5, 2012)
Added: pkg/vegan/man/simper.Rd
===================================================================
--- pkg/vegan/man/simper.Rd (rev 0)
+++ pkg/vegan/man/simper.Rd 2012-02-09 16:25:02 UTC (rev 2077)
@@ -0,0 +1,41 @@
+\name{simper}
+\alias{simper}
+\title{Similarity Percentages}
+
+\description{
+ Discriminating species between two groups using
+ Bray-Curtis dissimilarities
+}
+
+\usage{
+ simper(comm, group)
+}
+\arguments{
+ \item{comm}{Community data}
+
+ \item{group}{Vector assigning the groups}
+}
+\value{
+ A list of dataframes for every factor-combination.
+ \item{contr}{average contribution to overall
+ dissimilarity} \item{sd}{standard deviation of
+ contribution} \item{contr/sd}{mean to sd ratio}
+ \item{av_}{average abundance per group}
+ \item{cum}{cumulative per cent contribution}
+}
+
+\examples{
+data(dune)
+data(dune.env)
+with(dune.env, simper(dune, Management))
+}
+\author{
+ Eduard Szöcs \email{szoe8822 at uni-landau.de}
+}
+\references{
+ Clarke, K.R. 1993. Non-parametric multivariate analyses
+ of changes in community structure. \emph{Austral Ecology},
+ 18, 117–143.
+}
+\keyword{multivariate}
+
More information about the Vegan-commits
mailing list