[Vegan-commits] r245 - in pkg: R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Feb 25 13:09:14 CET 2008


Author: jarioksa
Date: 2008-02-25 13:09:14 +0100 (Mon, 25 Feb 2008)
New Revision: 245

Modified:
   pkg/R/biplot.rda.R
   pkg/man/biplot.rda.Rd
Log:
Needed a b/w biplot for a ms, and added 'col' argumnet to biplot.rda

Modified: pkg/R/biplot.rda.R
===================================================================
--- pkg/R/biplot.rda.R	2008-02-24 16:52:51 UTC (rev 244)
+++ pkg/R/biplot.rda.R	2008-02-25 12:09:14 UTC (rev 245)
@@ -5,13 +5,15 @@
 
 biplot.rda <- function(x, choices = c(1, 2), scaling = 2,
                        display = c("sites", "species"),
-                       type, xlim, ylim, ...) {
+                       type, xlim, ylim, col = c(1,2), ...) {
   if(!inherits(x, "rda"))
-    stop("'biplot.rda' is only for objects of class 'rda'")
+      stop("'biplot.rda' is only for objects of class 'rda'")
   if(!is.null(x$CCA))
-    stop("'biplot.rda' not suitable for models with constraints")
+      stop("'biplot.rda' not suitable for models with constraints")
   TYPES <- c("text", "points", "none")
   display <- match.arg(display, several.ok = TRUE)
+  if (length(col) == 1)
+      col <- c(col,col)
   g <- scores(x, choices = choices, display = display,
               scaling = scaling)
   if (!is.list(g)) {
@@ -19,19 +21,19 @@
       names(g) <- display
   }
   if (missing(type)) {
-    nitlimit <- 80
-    nit <- max(nrow(g$species), nrow(g$sites))
-    if (nit > nitlimit) 
-      type <- "points"
-    else type <- "text"
+      nitlimit <- 80
+      nit <- max(nrow(g$species), nrow(g$sites))
+      if (nit > nitlimit) 
+          type <- "points"
+      else type <- "text"
   }
   else type <- match.arg(type, TYPES, several.ok = TRUE)
   if(length(type) < 2)
-    type <- rep(type, 2)
+      type <- rep(type, 2)
   if (missing(xlim)) 
-    xlim <- range(g$species[, 1], g$sites[, 1])
+      xlim <- range(g$species[, 1], g$sites[, 1])
   if (missing(ylim)) 
-    ylim <- range(g$species[, 2], g$sites[, 2])
+      ylim <- range(g$species[, 2], g$sites[, 2])
   plot(g[[1]], xlim = xlim, ylim = ylim, type = "n", asp = 1, 
        ...)
   abline(h = 0, lty = 3)
@@ -43,16 +45,16 @@
           arrlen <- 0.85
       if (type[1] != "none")
           arrows(0, 0, g$species[,1] * arrlen, g$species[, 2] * arrlen,
-                 col = "red", length = 0.05)
+                 col = col[2], length = 0.05)
       if (type[1] == "text")
           text(g$species, rownames(g$species),
-               col = "red", cex = 0.7)
+               col = col[2], cex = 0.7)
   }
   if (!is.null(g$sites)) {
-    if (type[2] == "text") 
-      text(g$sites, rownames(g$sites), cex = 0.7)
-    else if (type[2] == "points") 
-      points(g$sites, pch = 1, cex = 0.7)
+      if (type[2] == "text") 
+          text(g$sites, rownames(g$sites), cex = 0.7, col = col[1])
+      else if (type[2] == "points") 
+          points(g$sites, pch = 1, cex = 0.7, col = col[1])
   }
   class(g) <- "ordiplot"
   invisible(g)

Modified: pkg/man/biplot.rda.Rd
===================================================================
--- pkg/man/biplot.rda.Rd	2008-02-24 16:52:51 UTC (rev 244)
+++ pkg/man/biplot.rda.Rd	2008-02-25 12:09:14 UTC (rev 245)
@@ -1,15 +1,15 @@
 \name{biplot.rda}
 \alias{biplot.rda}
-%- Also NEED an '\alias' for EACH other topic documented here.
+
 \title{PCA biplot}
 \description{
   Draws a PCA biplot with species scores indicated by biplot arrows
 }
 \usage{
 \method{biplot}{rda}(x, choices = c(1, 2), scaling = 2,
-       display = c("sites", "species"), type, xlim, ylim, ...)
+       display = c("sites", "species"), type, xlim, ylim, col = c(1,2), ...)
 }
-%- maybe also 'usage' for other objects documented here.
+
 \arguments{
   \item{x}{A \code{\link{rda}} result object.}
   \item{choices}{Axes to show.}
@@ -32,6 +32,8 @@
     element describes how species scores are handled, and the second how
     site scores are drawn.}
   \item{xlim, ylim}{the x and y limits (min, max) of the plot.}
+  \item{col}{Colours used for sites and species (in this order). If only
+    one colour is given, it is used for both.}
   \item{\dots}{Other parameters for plotting functions.}
 }
 \details{



More information about the Vegan-commits mailing list