[Vegan-commits] r2932 - pkg/vegan/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Feb 10 09:34:02 CET 2015


Author: jarioksa
Date: 2015-02-10 09:34:02 +0100 (Tue, 10 Feb 2015)
New Revision: 2932

Modified:
   pkg/vegan/R/centroids.cca.R
Log:
Merge branch 'cran-2.2' into r-forge-svn-local

Modified: pkg/vegan/R/centroids.cca.R
===================================================================
--- pkg/vegan/R/centroids.cca.R	2015-01-27 12:30:19 UTC (rev 2931)
+++ pkg/vegan/R/centroids.cca.R	2015-02-10 08:34:02 UTC (rev 2932)
@@ -17,13 +17,12 @@
     pnam <- labels(tmp)
     out <- NULL
     if (ncol(x) == 1) {
-        for(i in 1:length(tmp)) {
-            names(tmp[[i]]) <- paste(pnam[i], names(tmp[[i]]), sep="")
-            out <- c(out, tmp[[i]])
-            out <- matrix(out, nrow=1, dimnames = list(NULL, names(out)))
-        }  
+        nm <- unlist(sapply(pnam,
+                            function(nm) paste(nm, names(tmp[[nm]]), sep="")),
+                     use.names=FALSE)
+        out <- matrix(unlist(tmp), nrow=1, dimnames = list(NULL, nm))
     } else {
-        for (i in 1:length(tmp)) {
+        for (i in seq_along(tmp)) {
             colnames(tmp[[i]]) <- paste(pnam[i], colnames(tmp[[i]]), 
                                         sep = "")
             out <- cbind(out, tmp[[i]])



More information about the Vegan-commits mailing list