[Dplr-commits] r928 - in branches/teleconnections: . R data inst/doc inst/unitTests man vignettes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Dec 23 21:31:54 CET 2014


Author: mvkorpel
Date: 2014-12-23 21:31:53 +0100 (Tue, 23 Dec 2014)
New Revision: 928

Added:
   branches/teleconnections/.R/
   branches/teleconnections/00_README-developer
   branches/teleconnections/inst/unitTests/runit.utils.R
   branches/teleconnections/man/rasterPlot.Rd
Modified:
   branches/teleconnections/
   branches/teleconnections/.Rbuildignore
   branches/teleconnections/ChangeLog
   branches/teleconnections/DESCRIPTION
   branches/teleconnections/NAMESPACE
   branches/teleconnections/R/crn.plot.R
   branches/teleconnections/R/detrend.R
   branches/teleconnections/R/glk.R
   branches/teleconnections/R/latexify.R
   branches/teleconnections/R/rasterPlot.R
   branches/teleconnections/R/spag.plot.R
   branches/teleconnections/R/wavelet.plot.R
   branches/teleconnections/TODO
   branches/teleconnections/data/anos1.rda
   branches/teleconnections/data/ca533.rda
   branches/teleconnections/data/cana157.rda
   branches/teleconnections/data/co021.rda
   branches/teleconnections/data/gp.rwl.rda
   branches/teleconnections/inst/doc/
   branches/teleconnections/inst/doc/00_INDEX
   branches/teleconnections/inst/doc/math-dplR.R
   branches/teleconnections/inst/doc/math-dplR.Rnw.txt
   branches/teleconnections/inst/doc/math-dplR.bib
   branches/teleconnections/inst/doc/math-dplR.pdf
   branches/teleconnections/inst/unitTests/runit.dplR.R
   branches/teleconnections/man/glk.Rd
   branches/teleconnections/man/latexify.Rd
   branches/teleconnections/man/spag.plot.Rd
   branches/teleconnections/man/wavelet.plot.Rd
   branches/teleconnections/vignettes/
   branches/teleconnections/vignettes/dplR.sty
Log:
Merged changes from main development tree


Property changes on: branches/teleconnections
___________________________________________________________________
Modified: svn:ignore
   - dplR-Ex.R
svn*.tmp
.*
*~

   + dplR-Ex.R
svn*.tmp
.*
*~
.Rproj.user
*.Rproj

Modified: svn:mergeinfo
   - /branches/dplR-R-2.15:466-506
/branches/redfit:662-700
   + /branches/dplR-R-2.15:466-506
/branches/redfit:662-700
/pkg/dplR:898-927

Modified: branches/teleconnections/.Rbuildignore
===================================================================
--- branches/teleconnections/.Rbuildignore	2014-12-23 09:10:33 UTC (rev 927)
+++ branches/teleconnections/.Rbuildignore	2014-12-23 20:31:53 UTC (rev 928)
@@ -4,5 +4,9 @@
 ^(.*/)?\..+$
 ^inst/doc/cache(/.*)?$
 ^inst/doc/figure(/.*)?$
-^inst/doc/.*\.Rout$
+^inst/doc/.*\.(Rnw|Rout|aux|bbl|blg|fdb_latexmk|fls|glo|gls|glg|idx|ind|ilg|lof|log|lot|out|synctex.gz|tex|toc)$
 ^.*-tikzDictionary$
+^.*\.Rproj$
+^\.Rproj\.user$
+^.*/auto$
+^(|.*[^[:alpha:]])README-developer(|[^[:alpha:]].*)$

Copied: branches/teleconnections/00_README-developer (from rev 927, pkg/dplR/00_README-developer)
===================================================================
--- branches/teleconnections/00_README-developer	                        (rev 0)
+++ branches/teleconnections/00_README-developer	2014-12-23 20:31:53 UTC (rev 928)
@@ -0,0 +1,97 @@
+1. Introduction
+
+The (hidden) directory .R in the dplR source repository contains
+suggested R initialization files to use when building, checking and
+installing (compiling) the dplR package.  The initialization files
+should generally be placed in HOME/.R/ where HOME is the user's home
+directory.  Some customization may be required depending on the
+platform.  Check if the files already exist and combine the suggested
+"dplR settings" with your previous settings if appropriate.
+
+
+2. List of files included, and the settings explained
+
+* Makevars
+
+This file is used when R CMD INSTALL compiles the C source code
+included in dplR.  The compiler flags in the Makevars file should work
+with the GCC compiler.  Other compilers may require different flags.
+
+The following variables are set:
+
+CFLAGS=-Wall -pedantic -Wextra
+
+  The purpose of the flags is to enable more thorough warnings than
+  those used by default [1, Customizing package compilation].  The
+  warnings are useful in the development phase when making changes to
+  the C code.  Because all issues should be solved before releasing
+  the package on CRAN, there is no need to distribute a Makevars file
+  with dplR (as long as Makevars serves no other purpose than to add
+  more compile time checks).  Spurious warnings may occur when using
+  an old compiler.  A list of known cases:
+    - warning about imaginary constants being a GNU extension by
+      Apple's gcc 4.2, OS X 10.7
+
+Note that a matching platform-specific Makevars file
+(Makevars-R_PLATFORM, Makevars.win or Makevars.win64), if available,
+takes precedence over a generic Makevars file.  If you already have a
+platform-specific Makevars file, consider adding these definitions
+there.
+
+* build.Renviron
+
+This is used with R CMD build [2, Checking and building packages].
+The following environment variables are set:
+
+LC_ALL=en_US.UTF-8
+
+  The locale is set to use the UTF-8 character set and US English.
+  UTF-8 is used because dplR specifies UTF-8 as its Encoding in the
+  DESCRIPTION file.  The language setting may not matter, but one must
+  be chosen, and the en_US.UTF-8 locale is probably available on most
+  systems.
+
+_R_BUILD_COMPACT_VIGNETTES_=both
+
+  This enables the compression of vignettes and other PDFs, making the
+  dplR source package (.tar.gz) smaller.  The value "both" means that
+  two compression steps (lossy and lossless) are performed.  Two
+  programs must be available: Ghostscript [3] and QPDF [4].  Among
+  other things, the Ghostscript step applies lossy compression to
+  bitmap images using "ebook" quality (150 dpi) [5, 6].  This may
+  considerably reduce the size of the PDF.  QPDF performs a lossless
+  compression.  At the time of writing (dplR revision 908 on R-Forge,
+  Ghostscript 9.15, QPDF 5.12), the reduction in package size is 330
+  KiB (18 %).  [2, Building package tarballs; 7]
+
+* check.Renviron
+
+Settings for R CMD check [2, Checking and building packages]: locale
+as in build.Renviron.
+
+
+References
+
+[1] R Installation and Administration (R-devel).
+    http://cran.r-project.org/doc/manuals/r-devel/R-admin.html
+    (Accessed 2014-11-06)
+
+[2] Writing R Extensions (R-devel).
+    http://cran.r-project.org/doc/manuals/r-devel/R-exts.html
+    (Accessed 2014-11-06)
+
+[3] Ghostscript. http://ghostscript.com/ (Accessed 2014-11-06)
+
+[4] QPDF: A Content-Preserving PDF Transformation System.
+    http://qpdf.sourceforge.net/ (Accessed 2014-11-06)
+
+[5] File src/library/tools/R/build.R in the R source tree
+
+[6] compactPDF: Compact PDF Files.  Rd help page accessible by running
+    "?tools::compactPDF" in the R command prompt.
+
+[7] Help text of "R CMD build" command line tool.  Accessible by
+    running "R CMD build --help" in a command line interpreter.
+
+The version of R in 5, 6 and 7 was "R Under development (unstable)
+(2014-11-03 r66928)".

Modified: branches/teleconnections/ChangeLog
===================================================================
--- branches/teleconnections/ChangeLog	2014-12-23 09:10:33 UTC (rev 927)
+++ branches/teleconnections/ChangeLog	2014-12-23 20:31:53 UTC (rev 928)
@@ -1,11 +1,36 @@
 * CHANGES IN dplR VERSION 1.6.1
 
+
+File: glk.R and glk.Rd
+-------------
+- Modified by Christian Zang in reponse to a bug report by Allan Buras. In the
+  case of  no change from year i to year i+1 in both series then the glk sign
+  will for both be 0 and the sum of both is then also 0 and will not be 
+  accounted for correctly in the sum of synchronous years. Zang and Buras have
+  pached and Zang updates the help file to reflect the change as:
+  "This implementation improves the original formulation inasmuch as the case 
+  of neighbouring identical measurements in the same years is accounted for. 
+  Here, it is treated as full agreement, in contrast to only partial agreement 
+  in the original formulation.""
+
+File: crn.plot.R
+-------------
+
+- Removed automatic plotting of chronology name in main title.
+
+
+File: plot.wavelet.R
+-------------
+
+- Fixed small bug in ylim for the chronology in the plot.
+
 File: NAMESPACE
 ---------------
 
-- Added latexify() and latexDate() to export list
+- Added rasterPlot, latexify() and latexDate() to export list
 - Import readPNG from png.
 - Import more functions from grid.
+- Import stri_trans_nfc from stringi.
 
 File: DESCRIPTION
 -----------------
@@ -16,7 +41,7 @@
   math-dplR.pdf easier with openPDF().  RColorBrewer provides an
   alternative palette to an example in wavelet.plot.Rd.
 
-- New Imported package: png.
+- New Imported packages: png and stringi.
 
 File: chron.R
 -------------
@@ -46,6 +71,11 @@
 - Bug fix: Argument 'method' was not used for moving correlations.
   Instead, the method used was always "spearman".
 
+File: detrend.R
+---------------
+
+- Updated .export of foreach() to match previous changes to the loop body
+
 File: latexify.R
 ----------------
 
@@ -90,9 +120,8 @@
 New file rasterPlot.R
 ---------------------
 
-- New function rasterPlot(), internal to the package.  Adds a
-  raster image drawn with low level graphics commands to the current
-  high level plot.
+- New function rasterPlot().  Adds a raster image drawn with low
+  level graphics commands to the current high level plot.
 
 Files: rcompact.c, readloop.c
 -----------------------------
@@ -119,6 +148,14 @@
   plot with less than the full number of rows can fit in a smaller
   device and text on the sides won't be clipped.
 
+File: spag.plot.R
+-----------------
+
+- Added two options to spag.plot().
+  'useRaster': draw the tree-ring series as a raster image? (default
+     'FALSE')
+  'res': resolution of the tree-ring series when 'useRaster' is 'TRUE'
+
 File: timeseries-dplR.Rnw
 -------------------------
 
@@ -254,14 +291,14 @@
 
 File: corr.series.seg.R
 --------------------
-- Added method argument to specify method for cor.test(). Defauts to
+- Added method argument to specify method for cor.test(). Defaults to
   "spearman."
 
 File: corr.rwl.seg.R
 --------------------
 - Removed yr.range() function in favor of yr.range() in helpers.R.
   They are identical for all practical purposes.
-- Added method argument to specify method for cor.test(). Defauts to
+- Added method argument to specify method for cor.test(). Defaults to
   "spearman."
 File: interseries.cor.R
 -------------------------
@@ -363,7 +400,7 @@
 Files: exactsum.c, exactsum.h
 -----------------------------
 
-- Reuse of code between function by using the C preprocessor
+- Reuse of code between functions by using the C preprocessor
 - New (internal to dplR C code) function cumsum (cumulative sum,
   overwrites input array)
 - size_t n
@@ -371,7 +408,7 @@
 File: gini.c
 ------------
 
-- Simplified expression for gini coefficent reduces number of
+- Simplified expression for gini coefficient reduces number of
   arithmetic operations performed
 - Fewer calls to other functions (use of the new cumulative sum function)
 
@@ -631,7 +668,7 @@
 -------------------
 
 - Fixed trimming of all-NA rows
-- Fixed a bug that could crash R if the fided-width columns of the input
+- Fixed a bug that could crash R if the fixed-width columns of the input
   file did not follow the (loose) specifications of the Tucson format
 - AB: Note to dplR developers that this is a result of a poor standard in
   the Tucson format but this fix is needed to work with files that are
@@ -1989,7 +2026,7 @@
 
 2011-05-18 Andy  Bunn <andy.bunn at wwu.edu>
 * CHANGES IN dplR VERSION 1.4.0
-* Incporporation of TRiDAS via Mikko Korpela, May 16, 2011
+* Incorporation of TRiDAS via Mikko Korpela, May 16, 2011
 
 File: NAMESPACE
 ---------------
@@ -2070,7 +2107,7 @@
 2010-11-15 Andy  Bunn <andy.bunn at wwu.edu>
 * CHANGES IN dplR VERSION 1.3.9
 * Added an option to control the colors in plot.wavelet().
-* Added an option to plot wavelets side by side instead of stacked (plus a few owther beutifications).
+* Added an option to plot wavelets side by side instead of stacked (plus a few other beautifications).
 * Changes mostly in wavelet.plot.R and arg side.by.side and key.col added to the help.
 * Added an axis on side three for the wavelet plot.
 
@@ -2218,7 +2255,7 @@
 * Modified wavelet.plot() to produce a better looking plot and put the wavelet code into a new function called morlet().
 * Deprecated cwt.filled.contour
 * Added normalize1 to NAMESPACE
-* Added arguiment label.cex to pass to axis to increase the size of the labels on the plot in corr.rwl.seg() and modified 
+* Added argument label.cex to pass to axis to increase the size of the labels on the plot in corr.rwl.seg() and modified 
   the help file accordingly. This change was requested by a user and seems like a good idea.
 * Corrected some spelling in help for corr.rwl.seg(), ccf.series.seg(), and corr.series.seg(). I'm sure there is more.
 2010-07-17 Andy  Bunn <andy.bunn at wwu.edu>
@@ -2226,7 +2263,7 @@
 * Modified rcs() to stop() if any of the pith offsets are <1 or not integers. The help file indicated that this should
   be so but it's now explicit in the code.
 * Fixed a bug in corr.rwl.seg() where floating series were not being drawn properly - the plot had them displaying all the way to the 
-  max yr range b/c of an inexing problem. Also made some cosmetic changes to the guides in between segments for the graph. I do NOT
+  max yr range b/c of an indexing problem. Also made some cosmetic changes to the guides in between segments for the graph. I do NOT
   like the way the plot on this function is done with the odd bin and even bin looping. Very clunky and confusing to look at. The
   correlation part is fine and the graph is nice but the logic of the plot is silly.
 * Clarified language the help page for corr.rwl.seg().
@@ -2239,12 +2276,12 @@
   ccf.df$bin factor to be the same order as bins[,1].
 * Clarified language the help page for ccf.series.rwl().
 * Improved series.rwl.plot() to give more diagnostic information in four plots.
-* Improved the help page for series.rwl.plot() to beter explain what it now does.
+* Improved the help page for series.rwl.plot() to better explain what it now does.
 
 2010-07-05 Andy  Bunn <andy.bunn at wwu.edu>
 * CHANGES IN dplR VERSION 1.3.5
 * Modified the help file for write.crn() so that the elev in the hdr will be written in a way that might
-  be more robust in terms of the ITRDB standard. But, it's very clunky and silly to depend on an unrelaible
+  be more robust in terms of the ITRDB standard. But, it's very clunky and silly to depend on an unreliable
   standard. I also added some text to the help file for write.tucson() to indicate that the header should be thought
   of as experimental. Thank goodness Mikko is working on getting tridas implemented.
 * Fixed a bug in rcs() where the rc was calculated wrong if none. The function implicitly assumed 

Modified: branches/teleconnections/DESCRIPTION
===================================================================
--- branches/teleconnections/DESCRIPTION	2014-12-23 09:10:33 UTC (rev 927)
+++ branches/teleconnections/DESCRIPTION	2014-12-23 20:31:53 UTC (rev 928)
@@ -3,28 +3,30 @@
 Type: Package
 Title: Dendrochronology Program Library in R
 Version: 1.6.1
-Date: 2014-09-12
+Date: 2014-12-23
 Authors at R: c(person("Andy", "Bunn", role = c("aut", "cph",
         "cre", "trl"), email = "andy.bunn at wwu.edu"), person("Mikko",
         "Korpela", role = c("aut", "trl")), person("Franco", "Biondi",
         role = c("aut", "cph")), person("Filipe", "Campelo", role = 
         c("aut", "cph")), person("Pierre", "Mérian", role = c("aut", 
-        "cph")), person("Manfred", "Mudelsee", role = "aut"),
-        person("Fares", "Qeadan", role = c("aut", "cph")),
-        person("Michael", "Schulz", role = "aut"), person("Christian",
-        "Zang", role = c("aut", "cph")), person("Jacob", "Cecile",
-        role = "ctb"))
-Author: Andy Bunn [aut, cph, cre, trl], Mikko Korpela [aut, trl], Franco Biondi [aut, cph], Filipe Campelo [aut, cph], Pierre Mérian [aut, cph], Manfred Mudelsee [aut], Fares Qeadan [aut, cph], Michael Schulz [aut], Christian Zang [aut, cph], Jacob Cecile [ctb]
+        "cph")), person("Fares", "Qeadan", role = c("aut", "cph")),
+        person("Christian", "Zang", role = c("aut", "cph")),
+        person("Allan", "Buras", role = "ctb"), person("Jacob",
+        "Cecile", role = "ctb"), person("Manfred", "Mudelsee", role =
+        "ctb"), person("Michael", "Schulz", role = "ctb"))
+Author: Andy Bunn [aut, cph, cre, trl], Mikko Korpela [aut, trl], Franco Biondi [aut, cph], Filipe Campelo [aut, cph], Pierre Mérian [aut, cph], Fares Qeadan [aut, cph], Christian Zang [aut, cph], Allan Buras [ctb], Jacob Cecile [ctb], Manfred Mudelsee [ctb], Michael Schulz [ctb]
 Copyright: Authors and Aalto University (for work of M. Korpela)
 Maintainer: Andy Bunn <andy.bunn at wwu.edu>
 Depends: R (>= 2.15.0)
 Imports: gmp (>= 0.5-2), graphics, grDevices, grid, stats, utils,
         digest (>= 0.2.3), lattice (>= 0.13-6), png (>= 0.1-1),
-        stringr (>= 0.4), XML (>= 2.1-0)
+        stringi (>= 0.2-2), stringr (>= 0.4), XML (>= 2.1-0)
 Suggests: Biobase, dichromat (>= 1.2-3), foreach, forecast, iterators,
         knitr, RColorBrewer, RUnit (>= 0.4.25), tikzDevice, waveslim
 Description: This package contains functions for performing tree-ring
-        analyses, IO, and graphics.
+        analyses such as detrending, chronology building, and cross dating.
+        The package reads and writes standard file formats used in 
+        dendrochronology
 LazyData: no
 License: GPL (>= 2)
 URL: http://huxley.wwu.edu/trl/htrl-dplr,

Modified: branches/teleconnections/NAMESPACE
===================================================================
--- branches/teleconnections/NAMESPACE	2014-12-23 09:10:33 UTC (rev 927)
+++ branches/teleconnections/NAMESPACE	2014-12-23 20:31:53 UTC (rev 928)
@@ -22,6 +22,8 @@
 
 importFrom(png, readPNG)
 
+importFrom(stringi, stri_trans_nfc, stri_trans_nfd)
+
 importFrom(stringr, str_pad, str_trim)
 
 importFrom(utils, head, installed.packages, read.fwf, tail,
@@ -42,7 +44,7 @@
        write.compact, write.crn, write.rwl, write.tridas,
        write.tucson, plot.rwl, interseries.cor, summary.rwl,
        plot.crn, insert.ring, delete.ring, xskel.ccf.plot, xskel.plot,
-       latexify, latexDate)
+       latexify, latexDate, rasterPlot)
 
 S3method(print, redfit)
 S3method(plot, rwl)

Modified: branches/teleconnections/R/crn.plot.R
===================================================================
--- branches/teleconnections/R/crn.plot.R	2014-12-23 09:10:33 UTC (rev 927)
+++ branches/teleconnections/R/crn.plot.R	2014-12-23 20:31:53 UTC (rev 928)
@@ -33,8 +33,7 @@
   nyrs2 <- nyrs
   for(i in seq_len(nCrn)){
     spl <- crn[[i]]
-    plot(yr.vec, spl, type="n",axes=FALSE,
-         main=crn.names[i],...)
+    plot(yr.vec, spl, type="n",axes=FALSE,...)
     if(sd.exist) {
       par(new=TRUE)
       plot(yr.vec, samp.depth, type="n",

Modified: branches/teleconnections/R/detrend.R
===================================================================
--- branches/teleconnections/R/detrend.R	2014-12-23 09:10:33 UTC (rev 927)
+++ branches/teleconnections/R/detrend.R	2014-12-23 20:31:53 UTC (rev 928)
@@ -34,9 +34,7 @@
         ## a way to get rid of "no visible binding" NOTE in R CMD check
         rwl.i <- NULL
 
-        exportFun <- c("detrend.series", "is.data.frame",
-                       "row.names<-", "<-", "if")
-
+        exportFun <- c("names<-", "detrend.series")
         out <- foreach::"%dopar%"(foreach::foreach(rwl.i=it.rwl,
                                                    .export=exportFun),
                               {

Modified: branches/teleconnections/R/glk.R
===================================================================
--- branches/teleconnections/R/glk.R	2014-12-23 09:10:33 UTC (rev 927)
+++ branches/teleconnections/R/glk.R	2014-12-23 20:31:53 UTC (rev 928)
@@ -20,11 +20,11 @@
                     } else {
                         dif1 <- sign(diff(col1[not.na.both]))
                         dif2 <- sign(diff(col2[not.na.both]))
-                        G[i, k] <- sum(abs(dif1 + dif2)) / (2 * m - 2)
-                    }
-                }
-            }
-        }
-    }
+                        G[i, k] <- 1 - sum(abs(dif1 - dif2))/(2 * m - 2)
+                     }
+                  }
+              }
+          }
+      }
     G
 }

Modified: branches/teleconnections/R/latexify.R
===================================================================
--- branches/teleconnections/R/latexify.R	2014-12-23 09:10:33 UTC (rev 927)
+++ branches/teleconnections/R/latexify.R	2014-12-23 20:31:53 UTC (rev 928)
@@ -13,15 +13,11 @@
 
 ## Usage: \Sexpr{latexify(string_produced_by_R_code)}
 ##
-## Make arbitrary character() vector compatible with LaTeX by escaping
-## special characters, then convert to UTF-8 encoding.  Any formatting
-## (newlines, tabs, etc.) will be lost.  Note that the set of
-## characters actually supported depends on the font, LaTeX engine and
-## set of packages used.
-##
 ## It seems that Sweave needs doublebackslash = TRUE
 ## but knitr needs doublebackslash = FALSE.
-latexify <- function(x, doublebackslash=TRUE) {
+latexify <- function(x, doublebackslash = TRUE, dashdash = TRUE,
+                     quotes = c("straight", "curved"),
+                     packages = c("fontenc", "textcomp")) {
     y <- as.character(x)
     ## Kludge for converting from "byte" to the current encoding
     ## in a way which preserves the hex notation.
@@ -37,13 +33,26 @@
         cat(y[encBytes], sep = "\n")
         y[encBytes] <- foo
     }
+    l10n <- l10n_info()
+    Letters <- paste0(c(LETTERS, letters), collapse="")
+    fontenc <- "fontenc" %in% packages
+    textcomp <- "textcomp" %in% packages
+    eurosym <- "eurosym" %in% packages
+    straightQuotes <- match.arg(quotes) == "straight"
+    ## Remove control characters (not spaces!)
+    y <- gsub("(?![[:space:]])[[:cntrl:]]", "", y, perl=TRUE)
     ## Convert any sequence of whitespace to a single space.  This
     ## substitution must be done before control characters because
     ## newline belongs to both groups.
     y <- gsub("[[:space:]]+", " ", y)
-    ## Remove control characters
-    y <- gsub("[[:cntrl:]]", "", y)
-    ## Escape LaTeX special characters.
+
+    ## Handle LaTeX special characters in the ASCII range.
+    ## Some substitutions are mandatory, others affect matters such as
+    ## the rendering of the character in question (e.g. \textquote...)
+    ## or line breaks (\slash).  Some substitutions are unnecessary if
+    ## using a font encoding other than OT1 (\textbar, ...), but are
+    ## performed every time nonetheless.  The dash (-) is given
+    ## special treatment to disable the em and en dash ligatures.
     ## Source: Scott Pakin (2009) The Comprehensive LaTeX Symbol List.
     ## Accessible through "texdoc symbols".
     ## Particularly section 8.6 "ASCII and Latin 1 quick reference".
@@ -53,35 +62,290 @@
     ## Then, \ is replaced with \textbackslash{},
     ## but not if followed by { or }.
     ## After that, the order does not matter.
+    ##
+    ## This starts the 'substitutions' list, which is finally
+    ## processed close to the end of the function.
     substitutions <-
-        list(c("\\{", "\\\\{"),
-             c("\\}", "\\\\}"),
-             c("\\\\(?!(\\{|\\}))", "\\\\textbackslash{}"),
-             c("\\#", "\\\\#"),
-             c("\\$", "\\\\$"),
-             c("%", "\\\\%"),
-             c("\\^", "\\\\^{}"),
-             c("&", "\\\\&"),
-             c("_", "\\\\_"),
-             c("~", "\\\\~{}"),
-             c('"', "\\\\textquotedbl{}"),
+        list(c("([{}])", "\\\\\\1"),
+             c("\\\\(?![{}])", "\\\\textbackslash{}"),
+             c("\\^", "\\\\textasciicircum{}"),
+             c("~", "\\\\textasciitilde{}"),
+             c("<", "\\\\textless{}"),
+             c(">", "\\\\textgreater{}"),
+             c("\\|", "\\\\textbar{}"),
+             c("([#$%&_])", "\\\\\\1"),
+             if (isTRUE(dashdash)) {
+                 c("-", "\\\\mbox{-}")
+             },
+             if (textcomp && straightQuotes) {
+                 c("'", "\\\\textquotesingle{}")
+             },
+             if (textcomp && straightQuotes) {
+                 c("`", "\\\\textasciigrave{}")
+             },
+             c('"', if (fontenc && straightQuotes) {
+                 "\\\\textquotedbl{}"
+             } else {
+                 "\\\\textquotedblright{}"
+             }),
              c("/", "\\\\slash{}"))
+    substitutions <- substitutions[!vapply(substitutions, is.null, logical(1))]
+
+    ## Treatment of non-ASCII characters follows.
+
+    ## Digraphs and ligatures broken into their parts, except the
+    ## Dutch digraphs IJ and ij which have their own commands.
+    substitutions <-
+        c(substitutions,
+          list(c("\u0132", "\\\\IJ{}"),
+               c("\u0133", "\\\\ij{}"),
+               c("\u01f1", "DZ"),
+               c("\u01f2", "Dz"),
+               c("\u01f3", "dz"),
+               c("\u01c4", "DZ\u030c"),
+               c("\u01c5", "Dz\u030c"),
+               c("\u01c6", "dz\u030c"),
+               c("\u01c7", "LJ"),
+               c("\u01c8", "Lj"),
+               c("\u01c9", "lj"),
+               c("\u01ca", "NJ"),
+               c("\u01cb", "Nj"),
+               c("\u01cc", "nj"),
+               c("\ufb00", "ff"),
+               c("\ufb01", "fi"),
+               c("\ufb02", "fl"),
+               c("\ufb03", "ffi"),
+               c("\ufb04", "ffl"),
+               c("\ufb05", "\u017ft"),
+               c("\ufb06", "st")))
+
+    ## Accents (diacritics) above the letter (drop i and j dots)
+    above <- list(diaeresis   = c("\u0308", "\""),
+                  acute       = c("\u0301", "'"),
+                  dotabove    = c("\u0307", "."),
+                  macron      = c("\u0304", "="),
+                  circumflex  = c("\u0302", "^"),
+                  grave       = c("\u0300", "`"),
+                  tilde       = c("\u0303", "~"),
+                  doubleacute = c("\u030b", "H"),
+                  ringabove   = c("\u030a", "r"),
+                  breve       = c("\u0306", "u"),
+                  caron       = c("\u030c", "v"),
+                  invbreve    = c("\u0311", "newtie")) # textcomp
+    ## Accents that co-exist with i and j dots (mainly below the
+    ## letter, but also the ligature tie)
+    below <- list(macronbelow = c("\u0331", "b"),
+                  cedilla     = c("\u0327", "c"),
+                  dotbelow    = c("\u0323", "d"),
+                  tie         = c("\u0361", "t"),
+                  ogonek      = c("\u0328", "k")) # not in OT1 fontenc
+    accents <- c(above, below)
+    command <- paste0("\\\\[", Letters, "]+|\\\\.")
+    combining <- paste0(vapply(accents, "[", character(1), 1),
+                        collapse="")
+    accPre <- paste0("(", command, "|.)({})?(?<![", combining, "])")
+    accPost <- paste0("(?![", combining, "])")
+
+    ## Accent above the letter
+    aboveInCode <- vapply(above, "[", character(1), 1)
+    ijPattern <- paste0("([ij])", aboveInCode, accPost)
+    otherPattern <- paste0(accPre, aboveInCode, accPost)
+    aboveOutCode <- vapply(above, "[", character(1), 2)
+    ijReplacement <- paste0("\\\\", aboveOutCode, "{\\\\\\1}")
+    otherReplacement <- paste0("\\\\", aboveOutCode, "{\\1}")
+    ## for (accent in above) {
+    ##     code <- accent[1]
+    ##     replacement <- accent[2]
+    ##     y <- gsub(paste0("([ij])", code, accPost),
+    ##               paste0("\\\\", replacement, "{\\\\\\1}"), y, perl = TRUE)
+    ##     y <- gsub(paste0(accPre, code, accPost),
+    ##               paste0("\\\\", replacement, "{\\1}"), y, perl = TRUE)
+    ## }
+
+    ## Accent below the letter, and ligature tie
+    belowInCode <- vapply(below, "[", character(1), 1)
+    belowPattern <- paste0(accPre, belowInCode, accPost)
+    belowOutCode <- vapply(below, "[", character(1), 2)
+    belowReplacement <- paste0("\\\\", belowOutCode, "{\\1}")
+    ## for (accent in below) {
+    ##     code <- accent[1]
+    ##     replacement <- accent[2]
+    ##     y <- gsub(paste0(accPre, code, accPost),
+    ##               paste0("\\\\", replacement, "{\\1}"), y, perl = TRUE)
+    ## }
+
+    ## Combining an enclosing circle with an accent seems to work
+    circPre <- paste0("(", command, "({([^}]|\\\\})+})?|.)({})?")
+    circPattern <- paste0(circPre, "\u20dd", accPost)
+    circReplacement <- "\\\\textcircled{\\1}"
+
+    substitutions <-
+        c(substitutions,
+          lapply(lapply(mapply(list, list(as.name("c")),
+                               c(ijPattern, otherPattern,
+                                 belowPattern, circPattern),
+                               c(ijReplacement, otherReplacement,
+                                 belowReplacement, circReplacement),
+                               SIMPLIFY=FALSE), as.call), eval))
+
+    ## The output of sQuote() and dQuote() may contain non-ASCII
+    ## quoting characters.  If the input is ASCII, it may be a
+    ## surprise to the user that an UTF-8 input encoding is then
+    ## needed in LaTeX.  Converting the quotes to commands solves
+    ## this problem.  The substitution list also contains
+    ## non-ASCII letters and other unicode characters.
+    substitutions <-
+        c(substitutions,
+          list(c("\u00a1", "\\\\textexclamdown{}"),
+               c("\u00a3", "\\\\pounds{}"),
+               c("\u00a7", "\\\\S{}"),
+               c("\u00a9", "\\\\copyright{}"),
+               c("\u00aa", "\\\\textordfeminine{}"),
+               c("\u00ae", "\\\\textregistered{}"),
+               c("\u00b6", "\\\\P{}"),
+               c("\u00b7", "\\\\textperiodcentered{}"),
+               c("\u00ba", "\\\\textordmasculine{}"),
+               c("\u00bf", "\\\\textquestiondown{}"),
+               c("\u2013", "\\\\textendash{}"),
+               c("\u2014", "\\\\textemdash{}"),
+               c("\u2018", "\\\\textquoteleft{}"),
+               c("\u2019", "\\\\textquoteright{}"),
+               c("\u201c", "\\\\textquotedblleft{}"),
+               c("\u201d", "\\\\textquotedblright{}"),
+               c("\u2020", "\\\\dag{}"),
+               c("\u2021", "\\\\ddag{}"),
+               c("\u2022", "\\\\textbullet{}"),
+               c("\u2026", "\\\\dots{}"),
+               c("\u2122", "\\\\texttrademark{}"),
+               c("\u2423", "\\\\textvisiblespace{}"),
+               c("\u00c6", "\\\\AE{}"),
+               c("\u00e6", "\\\\ae{}"),
+               c("\u0152", "\\\\OE{}"),
+               c("\u0153", "\\\\oe{}"),
+               c("\u00d8", "\\\\O{}"),
+               c("\u00f8", "\\\\o{}"),
+               c("\u0141", "\\\\L{}"),
+               c("\u0142", "\\\\l{}"),
+               ## U+1E9E Latin capital letter sharp s. Works with
+               ## XeTeX and LuaTeX, provided that the character is
+               ## present in the font. Otherwise \SS, which usually
+               ## produces "SS".
+               c("\u1e9e", "\\\\ifdefined\\\\XeTeXrevision\\\\iffontchar\\\\font\"1E9E\\\\symbol{\"1E9E}\\\\else\\\\SS\\\\fi\\\\else\\\\ifdefined\\\\directlua\\\\iffontchar\\\\font\"1E9E\\\\symbol{\"1E9E}\\\\else\\\\SS\\\\fi\\\\else\\\\SS\\\\fi\\\\fi{}"),
+               c("\u00df", "\\\\ss{}"),
+               ## U+017F Latin small letter long s
+               c("\u017f", "\\\\ifdefined\\\\XeTeXrevision\\\\symbol{\"017F}\\\\else\\\\ifdefined\\\\directlua\\\\symbol{\"017F}\\\\else{\\\\fontencoding{TS1}\\\\selectfont s}\\\\fi\\\\fi{}")))
+    ## Other non-ASCII letters, punctuation marks.
+    ## These don't work with the OT1 font encoding.
+    substitutions <-
+        c(substitutions,
+          list(c("\u00d0", "\\\\DH{}"),
+               c("\u00f0", "\\\\dh{}"),
+               c("\u0110", "\\\\DJ{}"),
+               c("\u0111", "\\\\dj{}"),
+               c("\u014a", "\\\\NG{}"),
+               c("\u014b", "\\\\ng{}"),
+               c("\u00de", "\\\\TH{}"),
+               c("\u00fe", "\\\\th{}"),
+               c("\u00ab", "\\\\guillemotleft{}"),
+               c("\u00bb", "\\\\guillemotright{}"),
+               c("\u201a", "\\\\quotesinglbase{}"),
+               c("\u201e", "\\\\quotedblbase{}"),
+               c("\u2039", "\\\\guilsinglleft{}"),
+               c("\u203a", "\\\\guilsinglright{}")))
+    ## Miscellaneous, arrows, delimiters, legal symbols, science
+    ## and engineering, currencies, diacritics, text mode math.
+    ## These require textcomp.
+    substitutions <-
+        c(substitutions,
+          list(c("\u00a0", "~"),# no-break space (NBSP)
+               c("\u00ad", "\\\\-"),# soft hyphen (SHY)
+               c("\u200b", "\\\\hspace{0pt}"),# zero width space (ZWSP)
+               c("\u2217", "\\\\textasteriskcentered{}"),
+               c("\u2016", "\\\\textbardbl{}"),
+               c("\u25ef", "\\\\textbigcircle{}"),
+               c("\u2422", "\\\\textblank{}"),
+               c("\u00a6", "\\\\textbrokenbar{}"),
+               c("\u2052", "\\\\textdiscount{}"),
+               c("\u212e", "\\\\textestimated{}"),
+               c("\u203d", "\\\\textinterrobang{}"),
+               c("\u2e18", "\\\\textinterrobangdown{}"),
+               c("\u2116", "\\\\textnumero{}"),
+               c("\u25e6", "\\\\textopenbullet{}"),
+               c("\u2030", "\\\\textperthousand{}"),
+               c("\u2031", "\\\\textpertenthousand{}"),
+               c("\u211e", "\\\\textrecipe{}"),
+               c("\u203b", "\\\\textreferencemark{}"),
+               c("\u02f7", "\\\\texttildelow{}"),
+               c("\u2190", "\\\\textleftarrow{}"),
+               c("\u2191", "\\\\textuparrow{}"),
+               c("\u2192", "\\\\textrightarrow{}"),
+               c("\u2193", "\\\\textdownarrow{}"),
+               c("\u3008", "\\\\textlangle{}"),
+               c("\u3009", "\\\\textrangle{}"),
+               c("\u301a", "\\\\textlbrackdbl{}"),
+               c("\u301b", "\\\\textrbrackdbl{}"),
+               c("\u2045", "\\\\textlquill{}"),
+               c("\u2046", "\\\\textrquill{}"),
+               c("\u2117", "\\\\textcircledP{}"),
+               c("\u2120", "\\\\textservicemark{}"),
+               c("\u2103", "\\\\textcelsius{}"),
+               c("\u2127", "\\\\textmho{}"),
+               c("\u00b5", "\\\\textmu{}"),
+               c("\u03a9", "\\\\textohm{}"),
+               c("\u0e3f", "\\\\textbaht{}"),
+               c("\u00a2", "\\\\textcent{}"),
+               c("\u20a1", "\\\\textcolonmonetary{}"),
+               c("\u00a4", "\\\\textcurrency{}"),
+               c("\u20ab", "\\\\textdong{}"),
+               c("\u20ac", if (eurosym) "\\\\euro{}" else "\\\\texteuro{}"),
+               c("\u20b2", "\\\\textguarani{}"),
+               c("\u20a4", "\\\\textlira{}"),
+               c("\u20a6", "\\\\textnaira{}"),
+               c("\u20b1", "\\\\textpeso{}"),
+               c("\u20a9", "\\\\textwon{}"),
+               c("\u00a5", "\\\\textyen{}"),
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/dplr -r 928


More information about the Dplr-commits mailing list