[Vegan-commits] r2741 - pkg/permute/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Nov 21 21:31:07 CET 2013


Author: gsimpson
Date: 2013-11-21 21:31:07 +0100 (Thu, 21 Nov 2013)
New Revision: 2741

Modified:
   pkg/permute/R/print.permutationMatrix.R
Log:
 change the ordering and way that the information about the permutation design is printed.

Modified: pkg/permute/R/print.permutationMatrix.R
===================================================================
--- pkg/permute/R/print.permutationMatrix.R	2013-11-21 20:30:30 UTC (rev 2740)
+++ pkg/permute/R/print.permutationMatrix.R	2013-11-21 20:31:07 UTC (rev 2741)
@@ -8,14 +8,46 @@
     ## grab the permutation design
     ctrl <- attr(x, "control") ## gives us the list generated by how()
 
+    blocks <- getBlocks(ctrl)
+    plots <- getPlots(ctrl)
+
     ## print out dimensions of permutation matrix
-    msg <- paste("No. of Permutations: ", nrow(x), "; No. of Samples: ",
-                 ncol(x), sep = "")
+    msg <- paste("No. of Permutations: ", nrow(x), sep = "")
     writeLines(strwrap(msg))
 
+    ## print info on the within level
+    msg <- paste("No. of Samples:", ncol(x), "(")
+    if (any(pl <- !is.null(plots), bl <- !is.null(blocks))) {
+        msg <- paste(msg, "Nested in: ", sep = "")
+        if (pl && !bl) {
+            nmsg <- "plots; "
+        } else if (bl && !pl) {
+            nmsg <- "blocks; "
+        } else {
+            nmsg <- "plots & blocks; "
+        }
+        msg <- paste(msg, nmsg, sep = "")
+    }
+    wmsg <- switch(wt <- getType(ctrl, which = "within"),
+                   none = "",
+                   free = "Randomised",
+                   series = "Sequence",
+                   grid = paste("Spatial grid: ",
+                   getRow(ctrl, which = "within"), "r, ",
+                   getCol(ctrl, which = "within"), "c", sep = ""))
+    msg <- paste(msg, wmsg, sep = "")
+    ## add info on mirroring if series or grid
+    if ((wt %in% c("series", "grid")) && getMirror(ctrl, which = "within")) {
+        msg <- paste(msg, "; mirrored", sep = "")
+    }
+    ## add info on constant
+    if (getConstant(ctrl, which = "within") && pl) {
+        msg <- paste(msg, "; same permutation in each plot", sep = "")
+    }
+    writeLines(strwrap(paste(msg, ")", sep = "")))
+
     ## print info on blocking, but ONLY if set
     if (!is.null(blocks <- getBlocks(ctrl))) {
-        bl <- TRUE
         ll <- length(levels(blocks))
         msg <- paste("Restricted by Blocks: ", ctrl$blocks.name,
                      " (", ll, " ", if (ll == 1L) "block" else "blocks",
@@ -25,7 +57,7 @@
 
     ## print info on plots, but ONLY if set
     if (!is.null(strata <- getStrata(ctrl, which = "plots"))) {
-        pl <- TRUE
+        #pl <- TRUE
         plots <- getPlots(ctrl)
         pmsg <- switch(pt <- getType(ctrl, which = "plots"),
                         none = "",
@@ -45,36 +77,6 @@
         writeLines(strwrap(msg))
     }
 
-    ## print info on the within level
-    msg <- "Samples ("
-    if (any(pl, bl)) {
-        msg <- paste(msg, "Nested in: ", sep = "")
-        if (pl && !bl) {
-            nmsg <- "plots; "
-        } else if (bl && !pl) {
-            nmsg <- "blocks; "
-        } else {
-            nmsg <- "plots & blocks; "
-        }
-        msg <- paste(msg, nmsg, sep = "")
-    }
-    wmsg <- switch(wt <- getType(ctrl, which = "within"),
-                   none = "",
-                   free = "Randomised",
-                   series = "Sequence",
-                   grid = paste("Spatial grid: ",
-                   getRow(ctrl, which = "within"), "r, ",
-                   getCol(ctrl, which = "within"), "c", sep = ""))
-    msg <- paste(msg, wmsg, sep = "")
-    ## add info on mirroring if series or grid
-    if ((wt %in% c("series", "grid")) && getMirror(ctrl, which = "within")) {
-        msg <- paste(msg, "; mirrored", sep = "")
-    }
-    ## add info on constant
-    if (getConstant(ctrl, which = "within") && pl) {
-        msg <- paste(msg, "; same permutation in each plot", sep = "")
-    }
-    writeLines(strwrap(paste(msg, ")", sep = "")))
 
     cat("\n")
     x <- as.matrix(x)



More information about the Vegan-commits mailing list