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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Mar 30 00:12:51 CET 2014


Author: gsimpson
Date: 2014-03-30 00:12:50 +0100 (Sun, 30 Mar 2014)
New Revision: 2867

Modified:
   pkg/vegan/R/rarecurve.R
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/diversity.Rd
Log:
allow setting of per sample rarefaction line colour and type in rarecurve

Modified: pkg/vegan/R/rarecurve.R
===================================================================
--- pkg/vegan/R/rarecurve.R	2014-03-28 10:04:53 UTC (rev 2866)
+++ pkg/vegan/R/rarecurve.R	2014-03-29 23:12:50 UTC (rev 2867)
@@ -1,10 +1,18 @@
 `rarecurve` <-
     function(x, step = 1, sample, xlab = "Sample Size", ylab = "Species",
-             label = TRUE,...)
+             label = TRUE, col, lty, ...)
 {
+    ## sort out col and lty
+    if (missing(col))
+        col <- par("col")
+    if (missing(lty))
+        lty <- par("lty")
     tot <- rowSums(x)
     S <- specnumber(x)
     nr <- nrow(x)
+    ## rep col and lty to appropriate length
+    col <- rep(col, length.out = nr)
+    lty <- rep(lty, length.out = nr)
     ## Rarefy
     out <- lapply(seq_len(nr), function(i) {
         n <- seq(1, tot[i], by = step)
@@ -25,9 +33,9 @@
         abline(h = rare, lwd=0.5)
     }
     ## rarefaction curves
-    for(ln in seq_len(length(out))) {
+    for (ln in seq_len(length(out))) {
         N <- attr(out[[ln]], "Subsample")
-        lines(N, out[[ln]], ...)
+        lines(N, out[[ln]], col = col[ln], lty = lty[ln], ...)
     }
     ## label curves at their endpoitns
     if (label) {

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2014-03-28 10:04:53 UTC (rev 2866)
+++ pkg/vegan/inst/ChangeLog	2014-03-29 23:12:50 UTC (rev 2867)
@@ -4,7 +4,7 @@
 
 Version 2.1-41 (opened December 12, 2013)
 
-	* adipart, multipart, hiersimu: it is now an error to provide 
+	* adipart, multipart, hiersimu: it is now an error to provide
 	non-nested sampling hierarchy (used to be a warning).
 
 	* new version opened with the CRAN release of vegan_2.0-10 on
@@ -120,6 +120,10 @@
 	objects returned. Hence the logic in `plot.envfit()` when called
 	with argument `labels` was failing.
 
+	* rarecurve: line colour and type for each sample can now be
+	specified through formal arguments `col` and `lty`. Incidental
+	wish of http://stackoverflow.com/q/22714775/429846.
+
 Version 2.1-40 (closed December 12, 2013)	
 	
 	* anova.cca: Function is now based on the new code, but the old is

Modified: pkg/vegan/man/diversity.Rd
===================================================================
--- pkg/vegan/man/diversity.Rd	2014-03-28 10:04:53 UTC (rev 2866)
+++ pkg/vegan/man/diversity.Rd	2014-03-29 23:12:50 UTC (rev 2867)
@@ -19,7 +19,7 @@
 rrarefy(x, sample)
 drarefy(x, sample)
 rarecurve(x, step = 1, sample, xlab = "Sample Size", ylab = "Species",
-   label = TRUE, ...)
+          label = TRUE, col, lty, ...)
 fisher.alpha(x, MARGIN = 1, ...)
 specnumber(x, groups, MARGIN = 1)
 }
@@ -35,7 +35,11 @@
   \item{se}{Estimate standard errors.}
   \item{step}{Step size for sample sizes in rarefaction curves.}
   \item{xlab, ylab}{Axis labels in plots of rarefaction curves.}
-  \item{label}{Label rarefaction curves by rownames of \code{x} (logical).}
+  \item{label}{Label rarefaction curves by rownames of \code{x}
+    (logical).}
+  \item{col, lty}{plotting colour and line type, see
+    \code{\link{par}}. Can be a vector of length \code{nrow(x)}, one per
+    sample, and will be extended to such a length internally.}
   \item{groups}{A grouping factor: if given, finds the total number of
     species in each group.}
   \item{...}{Parameters passed to \code{\link{nlm}}, or to \code{\link{plot}}, 



More information about the Vegan-commits mailing list