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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Apr 4 14:48:38 CEST 2014


Author: mvkorpel
Date: 2014-04-04 14:48:38 +0200 (Fri, 04 Apr 2014)
New Revision: 764

Modified:
   pkg/dplR/ChangeLog
   pkg/dplR/DESCRIPTION
   pkg/dplR/R/write.compact.R
   pkg/dplR/R/write.crn.R
   pkg/dplR/R/write.rwl.R
   pkg/dplR/R/write.tridas.R
   pkg/dplR/R/write.tucson.R
   pkg/dplR/man/print.redfit.Rd
   pkg/dplR/man/write.compact.Rd
   pkg/dplR/man/write.crn.Rd
   pkg/dplR/man/write.rwl.Rd
   pkg/dplR/man/write.tridas.Rd
   pkg/dplR/man/write.tucson.Rd
Log:
* The write.* functions now return the name of the output file.  This
  is useful if the fname argument is a call that creates the file
  name, e.g. tempfile().  Previously there was (practically) no return
  value.  This should not break anything.
* Examples in the write.*.Rd files were modified to use tempfile()s
  instead of writing to the working directory, which was potentially
  harmful.


Modified: pkg/dplR/ChangeLog
===================================================================
--- pkg/dplR/ChangeLog	2014-04-04 09:13:17 UTC (rev 763)
+++ pkg/dplR/ChangeLog	2014-04-04 12:48:38 UTC (rev 764)
@@ -69,8 +69,8 @@
 - New wrapper to plot rwl objects. This is setting the
   stage for having plot, summary, etc. methods for rwl
   objects. There are still several things to work on. Like
-  setting the class() of rwl data objects via read.rwl (and in 
-  the onboard data sets). And will this class change break any 
+  setting the class() of rwl data objects via read.rwl (and in
+  the onboard data sets). And will this class change break any
   existing functions?
 
 File: spag.plot.R
@@ -106,6 +106,16 @@
   computed
 - Optimizations
 
+Files: write.compact.R, write.crn.R,
+write.rwl.R, write.tridas.R, write.tucson.R
+-------------------------------------------
+
+- The write.* functions now return the name of the output file.
+  Previously it was documented that there was no return value.
+- Examples in the corresponding .Rd files were modified to use
+  tempfile()s instead of writing to the working directory, which was
+  potentially harmful.
+
 * CHANGES IN dplR VERSION 1.5.9
 
 Files: dplR.h, rcompact.c, redfit.c

Modified: pkg/dplR/DESCRIPTION
===================================================================
--- pkg/dplR/DESCRIPTION	2014-04-04 09:13:17 UTC (rev 763)
+++ pkg/dplR/DESCRIPTION	2014-04-04 12:48:38 UTC (rev 764)
@@ -3,7 +3,7 @@
 Type: Package
 Title: Dendrochronology Program Library in R
 Version: 1.6.0
-Date: 2014-04-02
+Date: 2014-04-04
 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",

Modified: pkg/dplR/R/write.compact.R
===================================================================
--- pkg/dplR/R/write.compact.R	2014-04-04 09:13:17 UTC (rev 763)
+++ pkg/dplR/R/write.compact.R	2014-04-04 12:48:38 UTC (rev 764)
@@ -102,4 +102,5 @@
             cat(line.str, line.term, file=rwl.out, sep="")
         }
     }
+    fname
 }

Modified: pkg/dplR/R/write.crn.R
===================================================================
--- pkg/dplR/R/write.crn.R	2014-04-04 09:13:17 UTC (rev 763)
+++ pkg/dplR/R/write.crn.R	2014-04-04 12:48:38 UTC (rev 764)
@@ -129,4 +129,5 @@
         dec.str <- c(hdr, dec.str)
     }
     cat(dec.str, file = fname, sep = "\n", append=append)
+    fname
 }

Modified: pkg/dplR/R/write.rwl.R
===================================================================
--- pkg/dplR/R/write.rwl.R	2014-04-04 09:13:17 UTC (rev 763)
+++ pkg/dplR/R/write.rwl.R	2014-04-04 12:48:38 UTC (rev 764)
@@ -1,6 +1,8 @@
 write.rwl <-
     function(rwl.df, fname, format=c("tucson", "compact", "tridas"), ...)
 {
+    ## NOTE: This function is documented to return fname.  Therefore,
+    ## each branch of the switch must return fname.
     switch(match.arg(format),
            tucson = write.tucson(rwl.df, fname, ...),
            compact = write.compact(rwl.df, fname, ...),

Modified: pkg/dplR/R/write.tridas.R
===================================================================
--- pkg/dplR/R/write.tridas.R	2014-04-04 09:13:17 UTC (rev 763)
+++ pkg/dplR/R/write.tridas.R	2014-04-04 12:48:38 UTC (rev 764)
@@ -1063,4 +1063,5 @@
         }
     }
     doc.closeTag() # </project>
+    fname
 }

Modified: pkg/dplR/R/write.tucson.R
===================================================================
--- pkg/dplR/R/write.tucson.R	2014-04-04 09:13:17 UTC (rev 763)
+++ pkg/dplR/R/write.tucson.R	2014-04-04 12:48:38 UTC (rev 764)
@@ -242,4 +242,5 @@
                 file = rwl.out, sep="")
         }
     }
+    fname
 }

Modified: pkg/dplR/man/print.redfit.Rd
===================================================================
--- pkg/dplR/man/print.redfit.Rd	2014-04-04 09:13:17 UTC (rev 763)
+++ pkg/dplR/man/print.redfit.Rd	2014-04-04 12:48:38 UTC (rev 764)
@@ -75,8 +75,9 @@
 redf <- redfit(x[idx], t[idx], "time",
                nsim = 100, iwin = 0, ofac = 1, n50 = 1)
 print(redf)
-f <- tempfile()
+f <- tempfile(fileext=".csv")
 print(redf, csv.out = TRUE, file = f)
 redftable <- read.csv(f)
+unlink(f) # remove the file
 }
 \keyword{ print }

Modified: pkg/dplR/man/write.compact.Rd
===================================================================
--- pkg/dplR/man/write.compact.Rd	2014-04-04 09:13:17 UTC (rev 763)
+++ pkg/dplR/man/write.compact.Rd	2014-04-04 12:48:38 UTC (rev 764)
@@ -47,14 +47,16 @@
   list of the renamings (see Arguments).
 }
 \value{
-  None. Invoked for side effect (file is written).
- }
+  \code{\var{fname}}
+}
 \author{ Mikko Korpela, based on write.tucson by Andy Bunn }
 \seealso{ \code{\link{write.rwl}}, \code{\link{write.tucson}},
   \code{\link{write.tridas}}, \code{\link{read.compact}}
 }
 \examples{data(co021)
-write.compact(rwl.df = co021, fname = "tmp.rwl", append = FALSE,
-              prec = 0.001)
+fname <- write.compact(rwl.df = co021,
+                       fname = tempfile(fileext=".rwl"),
+                       append = FALSE, prec = 0.001)
+unlink(fname) # remove the file
 }
 \keyword{ IO }

Modified: pkg/dplR/man/write.crn.Rd
===================================================================
--- pkg/dplR/man/write.crn.Rd	2014-04-04 09:13:17 UTC (rev 763)
+++ pkg/dplR/man/write.crn.Rd	2014-04-04 12:48:38 UTC (rev 764)
@@ -70,15 +70,15 @@
   than crn files in terms of usefulness on the \acronym{ITRDB}.
 }
 \value{
-  None. Invoked for side effect (file is written).
- }
+  \code{\var{fname}}
+}
 \author{ Andy Bunn. Patched and improved by Mikko Korpela. }
 \seealso{ \code{\link{chron}}, \code{\link{read.crn}}
 }
 \examples{data(ca533)
 ca533.rwi <- detrend(rwl = ca533, method = "ModNegExp")
 ca533.crn <- chron(ca533.rwi, prefix = "CAM")
-write.crn(ca533.crn, "tmp.crn")
+fname1 <- write.crn(ca533.crn, tempfile(fileext=".crn"))
 ## Put the standard and residual chronologies in a single file
 ## with ITRDB header info on top. Not reccomended.
 ca533.crn <- chron(ca533.rwi, prefix = "CAM", prewhiten = TRUE)
@@ -88,7 +88,9 @@
                   long = -11813, first.yr = 626, last.yr = 1983,
                   lead.invs = "Donald A. Graybill, V.C. LaMarche, Jr.",
                   comp.date = "Nov1983")
-write.crn(ca533.crn[, -2], "tmp.crn", header = ca533.hdr)
-write.crn(ca533.crn[, -1], "tmp.crn", append = TRUE)
+fname2 <- write.crn(ca533.crn[, -2], tempfile(fileext=".crn"),
+                    header = ca533.hdr)
+write.crn(ca533.crn[, -1], fname2, append = TRUE)
+unlink(c(fname1, fname2)) # remove the files
 }
 \keyword{ IO }

Modified: pkg/dplR/man/write.rwl.Rd
===================================================================
--- pkg/dplR/man/write.rwl.Rd	2014-04-04 09:13:17 UTC (rev 763)
+++ pkg/dplR/man/write.rwl.Rd	2014-04-04 12:48:38 UTC (rev 764)
@@ -32,7 +32,7 @@
   write operation.
 }
 \value{
-  None. Invoked for side effect (file is written).
+  \code{\var{fname}}
 }
 \author{ Mikko Korpela }
 \seealso{ \code{\link{write.crn}}, \code{\link{write.tucson}},
@@ -46,7 +46,9 @@
                   spp = "DOUGLAS FIR", elev = 2103, lat = 3712,
                   long = -10830, first.yr = 1400, last.yr = 1963,
                   lead.invs = "E. SCHULMAN", comp.date = "")
-write.rwl(rwl.df = co021, fname = "tmp.rwl", format = "tucson",
-          header = co021.hdr, append = FALSE, prec = 0.001)
+fname <- write.rwl(rwl.df = co021, fname = tempfile(fileext=".rwl"),
+                   format = "tucson", header = co021.hdr,
+                   append = FALSE, prec = 0.001)
+unlink(fname) # remove the file
 }
 \keyword{ IO }

Modified: pkg/dplR/man/write.tridas.Rd
===================================================================
--- pkg/dplR/man/write.tridas.Rd	2014-04-04 09:13:17 UTC (rev 763)
+++ pkg/dplR/man/write.tridas.Rd	2014-04-04 12:48:38 UTC (rev 764)
@@ -335,7 +335,7 @@
 
 }
 
-\value{ None. Invoked for side effect (file is written).  }
+\value{ \code{\var{fname}} }
 
 \references{ TRiDaS \enc{–}{--} The Tree Ring Data Standard,
   \url{http://www.tridas.org/} }
@@ -363,11 +363,13 @@
 data(ca533)
 ca533.rwi <- detrend(rwl = ca533, method = "ModNegExp")
 ca533.crn <- chron(ca533.rwi, prefix = "CAM", prewhiten = TRUE)
-write.tridas(crn = ca533.crn, fname = "tmp2.xml",
+fname <- write.tridas(crn = ca533.crn,
+    fname = tempfile(fileext=".xml"),
     taxon = "Pinus longaeva D.K. Bailey",
     project.info =
         list(investigator = "Donald A. Graybill, V.C. LaMarche, Jr.",
              title = "Campito Mountain", category = "",
              period = "", type = "unknown"))
+unlink(fname) # remove the file
 }
 \keyword{ IO }

Modified: pkg/dplR/man/write.tucson.Rd
===================================================================
--- pkg/dplR/man/write.tucson.Rd	2014-04-04 09:13:17 UTC (rev 763)
+++ pkg/dplR/man/write.tucson.Rd	2014-04-04 12:48:38 UTC (rev 764)
@@ -93,8 +93,8 @@
   incompatibility with other software.
 }
 \value{
-  None. Invoked for side effect (file is written).
- }
+  \code{\var{fname}}
+}
 \author{ Andy Bunn. Patched and improved by Mikko Korpela. }
 \seealso{ \code{\link{write.crn}}, \code{\link{read.tucson}},
   \code{\link{write.rwl}}, \code{\link{write.compact}},
@@ -107,7 +107,8 @@
                   spp = "DOUGLAS FIR", elev = "2103M", lat = 3712,
                   long = -10830, first.yr = 1400, last.yr = 1963,
                   lead.invs = "E. SCHULMAN", comp.date = "")
-write.tucson(rwl.df = co021, fname = "tmp.rwl", header = co021.hdr,
-             append = FALSE, prec = 0.001)
+fname <- write.tucson(rwl.df = co021, fname = tempfile(fileext=".rwl"),
+                      header = co021.hdr, append = FALSE, prec = 0.001)
+unlink(fname) # remove the file
 }
 \keyword{ IO }



More information about the Dplr-commits mailing list