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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Aug 2 08:13:59 CEST 2011


Author: jarioksa
Date: 2011-08-02 08:13:57 +0200 (Tue, 02 Aug 2011)
New Revision: 1690

Modified:
   pkg/vegan/R/make.cepnames.R
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/make.cepnames.Rd
Log:
an element of flexibility and cleaner handling of dots in make.cepnames

Modified: pkg/vegan/R/make.cepnames.R
===================================================================
--- pkg/vegan/R/make.cepnames.R	2011-08-02 06:12:50 UTC (rev 1689)
+++ pkg/vegan/R/make.cepnames.R	2011-08-02 06:13:57 UTC (rev 1690)
@@ -1,13 +1,20 @@
-"make.cepnames" <-
-    function (names) 
+`make.cepnames` <-
+    function (names, seconditem = FALSE) 
 {
+    ## make valid names
     names <- make.names(names, unique = FALSE)
+    ## remove trailing and duplicated dots
+    names <- gsub("\\.[\\.]+", ".", names)
+    names <- gsub("\\.$", "", names)
+    ## split by dots and take 4 letters of each element (if several)
     names <- lapply(strsplit(names, "\\."), function(x) if (length(x) > 1) 
                     substring(x, 1, 4) else x )
+    ## Take first and last element or 8 characters if only one element
     names <- unlist(lapply(names, function(x) if (length(x) > 1)
-                           paste(x[c(1, length(x))], collapse = "")
+                           paste(x[c(1, if(seconditem) 2 else length(x))], collapse = "")
                            else x))
     names <- abbreviate(names, 8)
+    ## Final clean-up
     names <- make.names(names, unique = TRUE)
     names
 }

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2011-08-02 06:12:50 UTC (rev 1689)
+++ pkg/vegan/inst/ChangeLog	2011-08-02 06:13:57 UTC (rev 1690)
@@ -5,6 +5,17 @@
 Version 1.90-2 (opened July 23, 2011)
 
 	* ordilabel: gained argument 'select'.
+
+	* orditorp: works with NA scores.
+
+	* make.cepnames: ignores duplicated and trailing dots. It is
+	assumed that the names to be changed came via R make.names()
+	mechanism which changes all blanks and non-accepted characters to
+	dots, and this may give extra dots in names. Gained argument to
+	take the second item of the name instead of the last which may
+	help in names like "Vaccinium vitis-idaea" (which becomes
+	"Vaccinium.vitis.idaea" -> "Vaccidae") or names which have authors
+	or other rubbish at the end.
 	
 Version 1.90-1 (closed July 23, 2011)
 

Modified: pkg/vegan/man/make.cepnames.Rd
===================================================================
--- pkg/vegan/man/make.cepnames.Rd	2011-08-02 06:12:50 UTC (rev 1689)
+++ pkg/vegan/man/make.cepnames.Rd	2011-08-02 06:13:57 UTC (rev 1690)
@@ -12,23 +12,35 @@
   \code{\link{make.unique}} which adds numbers to the end of CEP names if needed.
 }
 \usage{
-make.cepnames(names)
+make.cepnames(names, seconditem = FALSE)
 }
 \arguments{
   \item{names}{The names to be formatted into CEP names. }
+  \item{seconditem}{Take always the second item of the original name
+    to the abbreviated name instead of the last original item
+    (default).}
 }
-\details{
-  Cornell Ecology Programs (CEP) used eight-letter abbreviations for
-  species and site names. In species, the names were formed by taking
-  four first letters of the generic name and four first letters of the
-  specific or subspecific epithet. The CEP names were originally used,
-  because old \code{FORTRAN IV} did not have \code{CHARACTER} data type,
-  but text  had to be stored in numerical variables, which in
-  popular computers could hold four characters. In modern times,
-  there is no reason for this limitation, but ecologists are used to
-  these names, and they may be practical to avoid congestion in
-  ordination plots. 
+
+\details{ Cornell Ecology Programs (CEP) used eight-letter
+  abbreviations for species and site names. In species, the names were
+  formed by taking four first letters of the generic name and four
+  first letters of the specific or subspecific epithet. The current
+  function first makes valid \R names using \code{\link{make.names}},
+  and then splits these into elemets. The CEP name is made by taking
+  the four first letters of the first element, and four first letters
+  of the last (default) or the second element (with \code{seconditem =
+  TRUE}). If there was only one name element, it is
+  \code{\link{abbreviate}}d to eight letters. Finally, the names are
+  made unique which may add numbers to duplicated names.
+  
+  The CEP names were originally used, because old \code{FORTRAN IV}
+  did not have \code{CHARACTER} data type, but text had to be stored
+  in numerical variables, which in popular computers could hold four
+  characters. In modern times, there is no reason for this limitation,
+  but ecologists are used to these names, and they may be practical to
+  avoid congestion in ordination plots.  
 }
+
 \value{
   Function returns CEP names.
 }



More information about the Vegan-commits mailing list