[Dplr-commits] r935 - in pkg/dplR: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jan 7 15:51:08 CET 2015


Author: mvkorpel
Date: 2015-01-07 15:51:08 +0100 (Wed, 07 Jan 2015)
New Revision: 935

Modified:
   pkg/dplR/ChangeLog
   pkg/dplR/DESCRIPTION
   pkg/dplR/NAMESPACE
   pkg/dplR/R/latexify.R
   pkg/dplR/man/latexify.Rd
Log:
* In latexify.R, using captureOutput() from R.utils (a new import)
  improves efficiency of latexify() with certain large inputs.  The
  previous solution to the handling of "bytes" was a home-baked one
  re-implementing parts of capture.output(), a function which I wasn't
  aware of until now.
* In DESCRIPTION, the order of packages in Imports was changed: "base"
  packages first, followed by "recommended" packages, then others.


Modified: pkg/dplR/ChangeLog
===================================================================
--- pkg/dplR/ChangeLog	2015-01-05 17:18:55 UTC (rev 934)
+++ pkg/dplR/ChangeLog	2015-01-07 14:51:08 UTC (rev 935)
@@ -4,8 +4,25 @@
 -----------------
 
 - A new field, MailingList, shows the address of the web interface
-  to the dplR-help mailing list hosted on Google Groups
+  to the dplR-help mailing list hosted on Google Groups.
+- New Imported package: R.utils.
 
+File: NAMESPACE
+---------------
+
+- Import captureOutput from R.utils.
+
+File: latexify.R
+----------------
+
+- Improved efficiency when handling a large number of strings with
+  the "bytes" Encoding.  The code now uses R.utils::captureOutput()
+  instead of a home-baked re-implementation of (parts of)
+  utils::capture.output(), which is also a more compact solution in
+  terms of lines of code in dplR.  See Henrik Bengtsson's notes at
+  http://www.jottr.org/2014/05/captureOutput.html (referenced on
+  2015-01-07).
+
 * CHANGES IN dplR VERSION 1.6.2
 
 No functional changes.  A unit test was changed so it would not fail

Modified: pkg/dplR/DESCRIPTION
===================================================================
--- pkg/dplR/DESCRIPTION	2015-01-05 17:18:55 UTC (rev 934)
+++ pkg/dplR/DESCRIPTION	2015-01-07 14:51:08 UTC (rev 935)
@@ -3,7 +3,7 @@
 Type: Package
 Title: Dendrochronology Program Library in R
 Version: 1.6.3
-Date: 2015-01-05
+Date: 2015-01-07
 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",
@@ -18,9 +18,9 @@
 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),
-        stringi (>= 0.2-2), stringr (>= 0.4), XML (>= 2.1-0)
+Imports: graphics, grDevices, grid, stats, utils, lattice (>= 0.13-6),
+        digest (>= 0.2.3), gmp (>= 0.5-2), png (>= 0.1-1), R.utils (>=
+        1.32.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

Modified: pkg/dplR/NAMESPACE
===================================================================
--- pkg/dplR/NAMESPACE	2015-01-05 17:18:55 UTC (rev 934)
+++ pkg/dplR/NAMESPACE	2015-01-07 14:51:08 UTC (rev 935)
@@ -22,6 +22,8 @@
 
 importFrom(png, readPNG)
 
+importFrom(R.utils, captureOutput)
+
 importFrom(stringi, stri_trans_nfc, stri_trans_nfd)
 
 importFrom(stringr, str_pad, str_trim)

Modified: pkg/dplR/R/latexify.R
===================================================================
--- pkg/dplR/R/latexify.R	2015-01-05 17:18:55 UTC (rev 934)
+++ pkg/dplR/R/latexify.R	2015-01-07 14:51:08 UTC (rev 935)
@@ -23,15 +23,7 @@
     ## in a way which preserves the hex notation.
     encBytes <- Encoding(y) == "bytes"
     if (any(encBytes)) {
-        foo <- character(0) # dummy line
-        tc <- textConnection("foo", "w", local = TRUE)
-        sink(tc)
-        on.exit(sink())
-        on.exit(close(tc), add = TRUE)
-        ## Embedded newlines (if any) in y[encBytes] will not cause
-        ## line breaks with cat().
-        cat(y[encBytes], sep = "\n")
-        y[encBytes] <- foo
+        y[encBytes] <- captureOutput(cat(y[encBytes], sep = "\n"))
     }
     l10n <- l10n_info()
     Letters <- paste0(c(LETTERS, letters), collapse="")

Modified: pkg/dplR/man/latexify.Rd
===================================================================
--- pkg/dplR/man/latexify.Rd	2015-01-05 17:18:55 UTC (rev 934)
+++ pkg/dplR/man/latexify.Rd	2015-01-07 14:51:08 UTC (rev 935)
@@ -63,7 +63,7 @@
 
   Before applying the substitutions described above, input elements with
   \code{\link{Encoding}} set to \code{"bytes"} are printed and the
-  result is captured using the current text encoding.  The result of
+  output is stored using \code{\link{captureOutput}}.  The result of
   this intermediate stage is \acronym{ASCII} text where some characters
   are shown as their byte codes using a hexadecimal pair prefixed with
   \code{"\\x"}.  This set includes tabs, newlines and control



More information about the Dplr-commits mailing list