[Vegan-commits] r1055 - in pkg/vegan: R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Oct 28 10:31:54 CET 2009


Author: jarioksa
Date: 2009-10-28 10:31:51 +0100 (Wed, 28 Oct 2009)
New Revision: 1055

Added:
   pkg/vegan/R/pcnm.R
   pkg/vegan/man/pcnm.Rd
Log:
Adding 'pcnm' from sedarVegan with history: Dray's original

Added: pkg/vegan/R/pcnm.R
===================================================================
--- pkg/vegan/R/pcnm.R	                        (rev 0)
+++ pkg/vegan/R/pcnm.R	2009-10-28 09:31:51 UTC (rev 1055)
@@ -0,0 +1,19 @@
+"pcnm" <-
+function(matdist,thresh=give.thresh(as.dist(matdist)))
+{
+    matdist <- as.matrix(matdist)
+   
+   
+            mattrunc <- ifelse(matdist >thresh, 4*thresh,matdist)
+    wa.old <- options()$warn
+    options(warn = -1)
+    mypcnm <- cmdscale(mattrunc,k=min(dim(matdist))-1,eig=TRUE)
+    eq0 <- apply(as.matrix(mypcnm$eig/max((mypcnm$eig))),1,function(x) identical(all.equal(x, 0), TRUE))
+    inf0 <- ifelse(mypcnm$eig<0,TRUE,FALSE)
+    res <- list()
+    res$values <- mypcnm$eig[!(eq0|inf0)]
+    res$vectors <- mypcnm$points[,!(eq0|inf0)]
+    res$vectors <- sweep(res$vectors,2,sqrt(res$values),"/")
+    options(warn = wa.old)
+    return(res)
+}

Added: pkg/vegan/man/pcnm.Rd
===================================================================
--- pkg/vegan/man/pcnm.Rd	                        (rev 0)
+++ pkg/vegan/man/pcnm.Rd	2009-10-28 09:31:51 UTC (rev 1055)
@@ -0,0 +1,35 @@
+\name{pcnm}
+\alias{pcnm}
+\title{ Function to compute classical PCNM(Principal Coordinates of Neighborhood Matrix). }
+\description{
+  This function computed classical PCNM by the principal coordinate analysis of a truncated distance matrix.
+}
+\usage{
+pcnm(matdist, thresh = give.thresh(as.dist(matdist)))
+}
+
+\arguments{
+  \item{matdist}{ A distance matrix. }
+  \item{thresh}{ A threshold value. }
+}
+
+\value{
+  A list of two elements:
+  \item{values }{Eigenvalues obtained by the principal coordinates analysis.}
+  \item{vectors }{Eigenvectors obtained by the principal coordinates analysis. They have been normalized to unit norm.}
+  
+}
+\references{ Borcard D. and Legendre P. (2002) All-scale spatial analysis of ecological data by means of principal coordinates of neighbour matrices. \emph{Ecological Modelling} \bold{153}, 51--68. }
+\author{ Stephane Dray }
+\seealso{ \code{\link{give.thresh}} }
+\examples{
+data(oribatid)
+pcnm1 <- pcnm(dist(oribatid$xy))
+par(mfrow=c(1,3))
+s.value(oribatid$xy,pcnm1$vectors[,1],cleg=0, sub="PCNM 1",csub=3)
+s.value(oribatid$xy,pcnm1$vectors[,2],cleg=0, sub="PCNM 2",csub=3)
+s.value(oribatid$xy,pcnm1$vectors[,3],cleg=0, sub="PCNM 3",csub=3)
+
+
+}
+\keyword{ spatial }



More information about the Vegan-commits mailing list