From noreply at r-forge.r-project.org Fri Apr 6 06:48:46 2018 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 6 Apr 2018 06:48:46 +0200 (CEST) Subject: [Dplr-commits] r1090 - in pkg/dplR: . R man vignettes Message-ID: <20180406044846.DFF2418A057@r-forge.r-project.org> Author: andybunn Date: 2018-04-06 06:48:45 +0200 (Fri, 06 Apr 2018) New Revision: 1090 Added: pkg/dplR/R/time.rwl.R pkg/dplR/man/time.rwl.Rd Modified: pkg/dplR/ChangeLog pkg/dplR/DESCRIPTION pkg/dplR/NAMESPACE pkg/dplR/R/cms.R pkg/dplR/R/plotRings.R pkg/dplR/R/seg.plot.R pkg/dplR/man/bai.in.Rd pkg/dplR/man/bai.out.Rd pkg/dplR/man/fill.internal.NA.Rd pkg/dplR/man/hanning.Rd pkg/dplR/man/morlet.Rd pkg/dplR/man/plotRings.Rd pkg/dplR/man/print.redfit.Rd pkg/dplR/man/redfit.Rd pkg/dplR/man/rwi.stats.running.Rd pkg/dplR/man/seg.plot.Rd pkg/dplR/man/skel.plot.Rd pkg/dplR/man/wavelet.plot.Rd pkg/dplR/vignettes/chron-dplR.Rnw pkg/dplR/vignettes/intro-dplR.Rnw pkg/dplR/vignettes/timeseries-dplR.Rnw pkg/dplR/vignettes/xdate-dplR.Rnw Log: Added time.rwl and time.crn as convenience functions to get years out of crn and rwl. Changes to Rd files to demonstrate. Modified: pkg/dplR/ChangeLog =================================================================== --- pkg/dplR/ChangeLog 2018-03-24 21:01:46 UTC (rev 1089) +++ pkg/dplR/ChangeLog 2018-04-06 04:48:45 UTC (rev 1090) @@ -2,6 +2,13 @@ - Note that Darwin Alexander Pucha Cofrep has been added as a developer to work on plotRings() etc. +File: time.rwl.R +---------------- + +- Two convenience functions time.rwl and time.crn which extract the row.names of + rwl and crn objects as numerics. Used as a S3 method with class rwl and class crn. + This resulted in various changes to Rd files to make use of this capability. + File: seg.plot.R ---------------- Modified: pkg/dplR/DESCRIPTION =================================================================== --- pkg/dplR/DESCRIPTION 2018-03-24 21:01:46 UTC (rev 1089) +++ pkg/dplR/DESCRIPTION 2018-04-06 04:48:45 UTC (rev 1090) @@ -3,7 +3,7 @@ Type: Package Title: Dendrochronology Program Library in R Version: 1.6.8 -Date: 2018-03-24 +Date: 2018-04-05 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", "cph", "trl")), person("Franco", "Biondi", Modified: pkg/dplR/NAMESPACE =================================================================== --- pkg/dplR/NAMESPACE 2018-03-24 21:01:46 UTC (rev 1089) +++ pkg/dplR/NAMESPACE 2018-04-06 04:48:45 UTC (rev 1090) @@ -52,10 +52,12 @@ write.tucson, plot.rwl, interseries.cor, summary.rwl, plot.crn, insert.ring, delete.ring, xskel.ccf.plot, xskel.plot, latexify, latexDate, rasterPlot, treeMean, rwl.report, print.rwl.report, - plotRings) + plotRings,time.rwl,time.crn) S3method(print, redfit) S3method(plot, rwl) S3method(plot, crn) S3method(summary, rwl) S3method(print, rwl.report) +S3method(time, rwl) +S3method(time, crn) Modified: pkg/dplR/R/cms.R =================================================================== --- pkg/dplR/R/cms.R 2018-03-24 21:01:46 UTC (rev 1089) +++ pkg/dplR/R/cms.R 2018-04-06 04:48:45 UTC (rev 1090) @@ -26,7 +26,7 @@ ## divide each series by c curve and restore to cal years rwi <- rwl2 - yrs <- as.numeric(row.names(rwi)) + yrs <- time(rwi) c.vec <- rep(as.numeric(NA), n.col) names(c.vec) <- col.names if(c.hat.t){ Modified: pkg/dplR/R/plotRings.R =================================================================== --- pkg/dplR/R/plotRings.R 2018-03-24 21:01:46 UTC (rev 1089) +++ pkg/dplR/R/plotRings.R 2018-04-06 04:48:45 UTC (rev 1090) @@ -1,7 +1,7 @@ plotRings <- function(year, trwN, trwS = NA_real_, - trwE = NA_real_, trwW = NA_real_, + trwE = NA_real_, trwW = NA_real_, + length.unit = "mm", animation = FALSE, - length.unit = "100 mm", sys.sleep = 0.2, year.labels = TRUE, d2pith = NA, Modified: pkg/dplR/R/seg.plot.R =================================================================== --- pkg/dplR/R/seg.plot.R 2018-03-24 21:01:46 UTC (rev 1089) +++ pkg/dplR/R/seg.plot.R 2018-04-06 04:48:45 UTC (rev 1090) @@ -6,6 +6,7 @@ } yr <- as.numeric(row.names(rwl)) first.year <- as.matrix(apply(rwl, 2, yr.range, yr.vec=yr))[1, ] + last.year <- as.matrix(apply(rwl, 2, yr.range, yr.vec=yr))[2, ] neworder <- order(first.year, decreasing=FALSE) segs <- rwl[, neworder, drop=FALSE] n.col <- ncol(segs) Added: pkg/dplR/R/time.rwl.R =================================================================== --- pkg/dplR/R/time.rwl.R (rev 0) +++ pkg/dplR/R/time.rwl.R 2018-04-06 04:48:45 UTC (rev 1090) @@ -0,0 +1,7 @@ +time.rwl <- function(x,...){ + as.numeric(rownames(x)) +} + +time.crn <- function(x,...){ + as.numeric(rownames(x)) +} Property changes on: pkg/dplR/R/time.rwl.R ___________________________________________________________________ Added: svn:eol-style + native Modified: pkg/dplR/man/bai.in.Rd =================================================================== --- pkg/dplR/man/bai.in.Rd 2018-03-24 21:01:46 UTC (rev 1089) +++ pkg/dplR/man/bai.in.Rd 2018-04-06 04:48:45 UTC (rev 1090) @@ -74,10 +74,10 @@ data(gp.d2pith) foo <- bai.in(rwl = gp.rwl, d2pith = gp.d2pith) foo.crn <- chron(foo) -yr <- as.numeric(rownames(foo.crn)) -plot(yr, foo.crn[, 1], type = "n", +yrs <- time(foo.crn) +plot(yrs, foo.crn[, 1], type = "n", xlab = "Year", ylab = expression(mm^2)) -lines(yr, foo.crn[, 1], col = "grey", lty = "dashed") -lines(yr, ffcsaps(foo.crn[, 1], nyrs = 32), col = "red", lwd = 2) +lines(yrs, foo.crn[, 1], col = "grey", lty = "dashed") +lines(yrs, ffcsaps(foo.crn[, 1], nyrs = 32), col = "red", lwd = 2) } \keyword{ manip } Modified: pkg/dplR/man/bai.out.Rd =================================================================== --- pkg/dplR/man/bai.out.Rd 2018-03-24 21:01:46 UTC (rev 1089) +++ pkg/dplR/man/bai.out.Rd 2018-04-06 04:48:45 UTC (rev 1090) @@ -79,10 +79,10 @@ gp.dbh2[, 2] <- (gp.dbh[, 2] - gp.dbh[, 3]) * 10 bar <- bai.out(rwl = gp.rwl, diam = gp.dbh2) bar.crn <- chron(bar) -yr <- as.numeric(rownames(bar.crn)) -plot(yr, bar.crn[, 1], type = "n", +yrs <- time(bar.crn) +plot(yrs, bar.crn[, 1], type = "n", xlab = "Year", ylab = expression(mm^2)) -lines(yr, bar.crn[, 1], col = "grey", lty = "dashed") -lines(yr, ffcsaps(bar.crn[, 1], nyrs = 32), col = "red", lwd = 2) +lines(yrs, bar.crn[, 1], col = "grey", lty = "dashed") +lines(yrs, ffcsaps(bar.crn[, 1], nyrs = 32), col = "red", lwd = 2) } \keyword{ manip } Modified: pkg/dplR/man/fill.internal.NA.Rd =================================================================== --- pkg/dplR/man/fill.internal.NA.Rd 2018-03-24 21:01:46 UTC (rev 1089) +++ pkg/dplR/man/fill.internal.NA.Rd 2018-04-06 04:48:45 UTC (rev 1090) @@ -65,14 +65,14 @@ x8=c(rnorm(8), NA, NA), x9=c(rnorm(5), NA, rnorm(3), NA)) row.names(foo) <- 1901:1910 - +class(foo) <- c("rwl","data.frame") fill.internal.NA(foo, fill=0) bar <- fill.internal.NA(foo, fill="Spline") baz <- fill.internal.NA(foo, fill="Linear") ## note differences in method "Spline" vs. "Linear" -yrs <- as.numeric(row.names(foo)) +yrs <- time(foo) plot(yrs, foo$x7, type="b", lwd=3) lines(yrs, bar$x7, col="red", lwd=2) lines(yrs, baz$x7, col="green", lwd=1) Modified: pkg/dplR/man/hanning.Rd =================================================================== --- pkg/dplR/man/hanning.Rd 2018-03-24 21:01:46 UTC (rev 1089) +++ pkg/dplR/man/hanning.Rd 2018-04-06 04:48:45 UTC (rev 1090) @@ -30,7 +30,7 @@ \examples{library(graphics) library(utils) data(ca533) -yrs <- as.numeric(rownames(ca533)) +yrs <- time(ca533) y <- ca533[, 1] not.na <- !is.na(y) yrs <- yrs[not.na] Modified: pkg/dplR/man/morlet.Rd =================================================================== --- pkg/dplR/man/morlet.Rd 2018-03-24 21:01:46 UTC (rev 1089) +++ pkg/dplR/man/morlet.Rd 2018-04-06 04:48:45 UTC (rev 1090) @@ -49,7 +49,7 @@ data(ca533) ca533.rwi <- detrend(rwl = ca533, method = "ModNegExp") ca533.crn <- chron(ca533.rwi, prefix = "CAM", prewhiten = FALSE) -Years <- as.numeric(rownames(ca533.crn)) +Years <- time(ca533.crn) CAMstd <- ca533.crn[, 1] out.wave <- morlet(y1 = CAMstd, x1 = Years, dj = 0.1, siglvl = 0.99) } Modified: pkg/dplR/man/plotRings.Rd =================================================================== --- pkg/dplR/man/plotRings.Rd 2018-03-24 21:01:46 UTC (rev 1089) +++ pkg/dplR/man/plotRings.Rd 2018-04-06 04:48:45 UTC (rev 1090) @@ -110,7 +110,7 @@ # with tree-ring series from Rothenburg data data("anos1") -yrs <- as.numeric(rownames(anos1)) +yrs <- time(anos1) # Plot rings with data of two radii from same individual tree res <- plotRings(yrs, anos1[,4], trwW = anos1[,5], species.name = "Cedrela odorata") @@ -150,16 +150,17 @@ trw01.w = abs(rnorm(100, 10, 2.5)), # West direction trw01.e = abs(rnorm(100, 10, 2.5)), # East direction row.names = 1918:2017) +class(trw) <- c("rwl","data.frame") -year <- as.numeric(rownames(trw)) +yrs <- time(trw) # Default plot with 2, 3 and 4 radii -res <- plotRings(year, trw[,1], trw[,2], trw[,3], trw[,4]) +res <- plotRings(yrs, trw[,1], trw[,2], trw[,3], trw[,4]) # with d2pith values (see the hole before the first rings in the plot) -res <- plotRings(year, trw[,1], trw[,2], trw[,3], trw[,4], +res <- plotRings(yrs, trw[,1], trw[,2], trw[,3], trw[,4], d2pith = 500) -res <- plotRings(year, trw[,1], trw[,2], trw[,3], trw[,4], +res <- plotRings(yrs, trw[,1], trw[,2], trw[,3], trw[,4], d2pith = c(200, NA, NA, 50)) } Modified: pkg/dplR/man/print.redfit.Rd =================================================================== --- pkg/dplR/man/print.redfit.Rd 2018-03-24 21:01:46 UTC (rev 1089) +++ pkg/dplR/man/print.redfit.Rd 2018-04-06 04:48:45 UTC (rev 1090) @@ -71,17 +71,16 @@ } \examples{library(utils) data(ca533) -t <- as.numeric(row.names(ca533)) +tm <- time(ca533) x <- ca533[[1]] idx <- which(!is.na(x)) -redf <- redfit(x[idx], t[idx], "time", +redf <- redfit(x[idx], tm[idx], "time", nsim = 100, iwin = 0, ofac = 1, n50 = 1) print(redf) fname <- tempfile(fileext=".csv") print(fname) # tempfile used for output print(redf, csv.out = TRUE, file = fname) redftable <- read.csv(fname) - unlink(fname) # remove the file } \keyword{ print } Modified: pkg/dplR/man/redfit.Rd =================================================================== --- pkg/dplR/man/redfit.Rd 2018-03-24 21:01:46 UTC (rev 1089) +++ pkg/dplR/man/redfit.Rd 2018-04-06 04:48:45 UTC (rev 1090) @@ -373,7 +373,7 @@ library(utils) data(cana157) -yrs <- as.numeric(rownames(cana157)) +yrs <- time(cana157) x <- cana157[, 1] redf.x <- redfit(x, nsim = 1000) Modified: pkg/dplR/man/rwi.stats.running.Rd =================================================================== --- pkg/dplR/man/rwi.stats.running.Rd 2018-03-24 21:01:46 UTC (rev 1089) +++ pkg/dplR/man/rwi.stats.running.Rd 2018-04-06 04:48:45 UTC (rev 1090) @@ -244,7 +244,7 @@ gp.crn <- chron(gp.rwi) ## Running stats on the rwi with an window foo <- rwi.stats.running(gp.rwi, gp.ids, window.length = 80) - yrs <- as.numeric(rownames(gp.crn)) + yrs <- time(gp.crn) bar <- data.frame(yrs = c(min(yrs), foo$mid.year, max(yrs)), eps = c(NA, foo$eps, NA)) par(mar = c(2, 2, 2, 2), mgp = c(1.1, 0.1, 0), tcl = 0.25, Modified: pkg/dplR/man/seg.plot.Rd =================================================================== --- pkg/dplR/man/seg.plot.Rd 2018-03-24 21:01:46 UTC (rev 1089) +++ pkg/dplR/man/seg.plot.Rd 2018-04-06 04:48:45 UTC (rev 1090) @@ -25,6 +25,6 @@ \seealso{ \code{\link{spag.plot}} } \examples{library(utils) data(co021) -seg.plot(co021, main = "Campito Mountain") +seg.plot(co021) } \keyword{ hplot } Modified: pkg/dplR/man/skel.plot.Rd =================================================================== --- pkg/dplR/man/skel.plot.Rd 2018-03-24 21:01:46 UTC (rev 1089) +++ pkg/dplR/man/skel.plot.Rd 2018-04-06 04:48:45 UTC (rev 1090) @@ -79,7 +79,7 @@ \examples{library(utils) data(co021) x <- co021[,33] -x.yrs <- as.numeric(rownames(co021)) +x.yrs <- time(co021) x.name <- colnames(co021)[33] ## On a raw ring width series - undated skel.plot(x) @@ -89,7 +89,7 @@ library(grDevices) ## Try cross-dating y <- co021[, 11] -y.yrs <- as.numeric(rownames(co021)) +y.yrs <- time(co021) y.name <- colnames(co021)[11] ## send to postscript - 3 pages total Added: pkg/dplR/man/time.rwl.Rd =================================================================== --- pkg/dplR/man/time.rwl.Rd (rev 0) +++ pkg/dplR/man/time.rwl.Rd 2018-04-06 04:48:45 UTC (rev 1090) @@ -0,0 +1,36 @@ +\encoding{UTF-8} +\name{time.rwl} +\alias{time.rwl} +\alias{time.crn} +\title{ + Return time values for rwl and crn objects +} +\description{ + Returns the time values for rwl and crn objects. +} +\usage{ +\method{time}{rwl}(x, ...) +\method{time}{crn}(x, ...) +} +\arguments{ + + \item{x}{ An object of class \code{"rwl"} or an aboject of class \code{"crn"}. } + + \item{\dots}{ Not used. } +} +\value{ + A \code{numeric} vector of time (typically in years) for the object. This is done via \code{as.numeric(rownames(x))} but has been asked for by users so many times that it is being included as a function. +} +\author{ + Andy Bunn +} +\seealso{ + \code{\link{read.rwl}} + \code{\link{read.crn}} +} +\examples{ +library(utils) +data(co021) +co021.yrs <- time(co021) +} +\keyword{ manip } Property changes on: pkg/dplR/man/time.rwl.Rd ___________________________________________________________________ Added: svn:eol-style + native Modified: pkg/dplR/man/wavelet.plot.Rd =================================================================== --- pkg/dplR/man/wavelet.plot.Rd 2018-03-24 21:01:46 UTC (rev 1089) +++ pkg/dplR/man/wavelet.plot.Rd 2018-04-06 04:48:45 UTC (rev 1090) @@ -99,7 +99,7 @@ data(ca533) ca533.rwi <- detrend(rwl = ca533, method = "ModNegExp") ca533.crn <- chron(ca533.rwi, prefix = "CAM", prewhiten = FALSE) -Years <- as.numeric(rownames(ca533.crn)) +Years <- time(ca533.crn) CAMstd <- ca533.crn[, 1] out.wave <- morlet(y1 = CAMstd, x1 = Years, p2 = 9, dj = 0.1, siglvl = 0.99) Modified: pkg/dplR/vignettes/chron-dplR.Rnw =================================================================== --- pkg/dplR/vignettes/chron-dplR.Rnw 2018-03-24 21:01:46 UTC (rev 1089) +++ pkg/dplR/vignettes/chron-dplR.Rnw 2018-04-06 04:48:45 UTC (rev 1090) @@ -178,7 +178,7 @@ wa082.ids <- autoread.ids(wa082) eps.cut <- 0.75 # An arbitrary EPS cutoff for demonstration wa082.rwi.stats <- rwi.stats.running(wa082.rwi, wa082.ids, window.length = 30) -yrs <- as.numeric(rownames(wa082.crn)) +yrs <- time(wa082.crn) bar <- data.frame(yrs = c(min(yrs), wa082.rwi.stats$mid.year, max(yrs)), eps = c(NA, wa082.rwi.stats$eps, NA)) op <- par(no.readonly=TRUE) Modified: pkg/dplR/vignettes/intro-dplR.Rnw =================================================================== --- pkg/dplR/vignettes/intro-dplR.Rnw 2018-03-24 21:01:46 UTC (rev 1089) +++ pkg/dplR/vignettes/intro-dplR.Rnw 2018-04-06 04:48:45 UTC (rev 1090) @@ -313,7 +313,7 @@ ## based on EPS. Running stats on the rwi with a window. foo <- rwi.stats.running(ca533.rwi, ca533.ids, window.length = 80) -yrs <- as.numeric(rownames(ca533.crn)) +yrs <- time(ca533.crn) bar <- data.frame(yrs = c(min(yrs), foo$mid.year, max(yrs)), eps = c(NA, foo$eps, NA)) par(mar = c(2, 2, 2, 2), mgp = c(1.1, 0.1, 0), tcl = 0.25, Modified: pkg/dplR/vignettes/timeseries-dplR.Rnw =================================================================== --- pkg/dplR/vignettes/timeseries-dplR.Rnw 2018-03-24 21:01:46 UTC (rev 1089) +++ pkg/dplR/vignettes/timeseries-dplR.Rnw 2018-04-06 04:48:45 UTC (rev 1090) @@ -236,7 +236,7 @@ the result via \code{wavelet.plot}. <>= -yrs <- as.numeric(rownames(co021.crn)) +yrs <- time(co021.crn) out.wave <- morlet(y1 = dat, x1 = yrs, p2 = 8, dj = 0.1, siglvl = 0.99) wavelet.plot(out.wave, useRaster=NA, reverse.y = TRUE) Modified: pkg/dplR/vignettes/xdate-dplR.Rnw =================================================================== --- pkg/dplR/vignettes/xdate-dplR.Rnw 2018-03-24 21:01:46 UTC (rev 1089) +++ pkg/dplR/vignettes/xdate-dplR.Rnw 2018-04-06 04:48:45 UTC (rev 1090) @@ -186,7 +186,7 @@ <>= win <- 1800:1960 -dat.yrs <- as.numeric(rownames(dat)) +dat.yrs <- time(dat) dat.trunc <- dat[dat.yrs %in% win, ] ccf.30 <- ccf.series.rwl(rwl=dat.trunc, series="643114", seg.length=30, bin.floor=50) From noreply at r-forge.r-project.org Sat Apr 7 02:43:01 2018 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 7 Apr 2018 02:43:01 +0200 (CEST) Subject: [Dplr-commits] r1091 - in pkg/dplR: . R man Message-ID: <20180407004302.0090418953A@r-forge.r-project.org> Author: andybunn Date: 2018-04-07 02:43:01 +0200 (Sat, 07 Apr 2018) New Revision: 1091 Added: pkg/dplR/R/csv2rwl.R pkg/dplR/man/csv2rwl.Rd Modified: pkg/dplR/ChangeLog pkg/dplR/NAMESPACE pkg/dplR/R/read.rwl.R pkg/dplR/man/read.rwl.Rd Log: Adding new function to read csv files in as rwl objects. Also adding that capability into read.rwl. Mikko should see if the error checks etc pass muster. Modified: pkg/dplR/ChangeLog =================================================================== --- pkg/dplR/ChangeLog 2018-04-06 04:48:45 UTC (rev 1090) +++ pkg/dplR/ChangeLog 2018-04-07 00:43:01 UTC (rev 1091) @@ -2,6 +2,14 @@ - Note that Darwin Alexander Pucha Cofrep has been added as a developer to work on plotRings() etc. +File: csv2rwl.R +---------------- +Adding new function to read csv files in as rwl objects. Also adding that capability into read.rwl. Mikko should see if the error checks etc pass muster. + +File: read.rwl.R +---------------- +Adding read2csv into read.rwl both as a format specification and as an auto detect. Mikko should see if the error checks etc pass muster. + File: time.rwl.R ---------------- Modified: pkg/dplR/NAMESPACE =================================================================== --- pkg/dplR/NAMESPACE 2018-04-06 04:48:45 UTC (rev 1090) +++ pkg/dplR/NAMESPACE 2018-04-07 00:43:01 UTC (rev 1091) @@ -52,7 +52,7 @@ write.tucson, plot.rwl, interseries.cor, summary.rwl, plot.crn, insert.ring, delete.ring, xskel.ccf.plot, xskel.plot, latexify, latexDate, rasterPlot, treeMean, rwl.report, print.rwl.report, - plotRings,time.rwl,time.crn) + plotRings,time.rwl,time.crn,csv2rwl) S3method(print, redfit) S3method(plot, rwl) Added: pkg/dplR/R/csv2rwl.R =================================================================== --- pkg/dplR/R/csv2rwl.R (rev 0) +++ pkg/dplR/R/csv2rwl.R 2018-04-07 00:43:01 UTC (rev 1091) @@ -0,0 +1,8 @@ +`csv2rwl` <- function(fname,...) +{ + dat <- read.table(fname, header=TRUE, sep=",",...) + rownames(dat) <- as.character(dat[,1]) + dat <- dat[,-1] + class(dat) <- c("rwl","data.frame") + dat +} Property changes on: pkg/dplR/R/csv2rwl.R ___________________________________________________________________ Added: svn:eol-style + native Modified: pkg/dplR/R/read.rwl.R =================================================================== --- pkg/dplR/R/read.rwl.R 2018-04-06 04:48:45 UTC (rev 1090) +++ pkg/dplR/R/read.rwl.R 2018-04-07 00:43:01 UTC (rev 1091) @@ -1,57 +1,69 @@ read.rwl <- - function(fname, - format=c("auto", "tucson", "compact", "tridas", "heidelberg"), - ...) -{ + function(fname, + format=c("auto", "tucson", "compact", "tridas", "heidelberg", "csv"), + ...) + { switch(match.arg(format), auto = { - f <- file(fname,"r") - l1 <- readLines(f, n=1) - if(length(l1) == 0){ - close(f) - stop("file is empty") - } - ## A rough test for a compact format file - if(grepl("[1-9][0-9]*\\([1-9][0-9]*F[1-9][0-9]*\\.0\\)~ *$", - l1)){ - cat(gettext("Detected a DPL compact format file.\n", + cat(gettext("Attempting to automatically detect format.\n", + domain="R-dplR")) + f <- file(fname,"r") + l1 <- readLines(f, n=1) + if(length(l1) == 0){ + close(f) + stop("file is empty") + } + ## A rough test for a compact format file + if(grepl("[1-9][0-9]*\\([1-9][0-9]*F[1-9][0-9]*\\.0\\)~ *$", + l1)){ + cat(gettext("Detected a DPL compact format file.\n", + domain="R-dplR")) + close(f) + read.compact(fname, ...) + } + else if(grepl("^HEADER:$", l1)){ # Heidelberg test + cat(gettext("Detected a Heidelberg format file.\n", + domain="R-dplR")) + close(f) + read.fh(fname, ...) + } + else { # two tests for tridas + ## A rough test for a TRiDaS file + if(grepl("", l1)){ + cat(gettext("Detected a TRiDaS file.\n", + domain="R-dplR")) + close(f) + read.tridas(fname, ...) + } + else { + ## may be preceded by an XML + ## declaration, comments, etc. Therefore, if + ## the first line did not contain , we + ## read a "reasonable number" of additional + ## lines, and try to detect in those. + more.lines <- readLines(f, n=20) + close(f) + if(any(grepl("", more.lines))){ + cat(gettext("Detected a TRiDaS file.\n", domain="R-dplR")) - close(f) - read.compact(fname, ...) - } else if(grepl("^HEADER:$", l1)){ # Heidelberg test - cat(gettext("Detected a Heidelberg format file.\n", + read.tridas(fname, ...) + } + else if(grepl(",", l1)){ + cat(gettext("Detected a csv file.\n", domain="R-dplR")) - close(f) - read.fh(fname, ...) - } else { - ## A rough test for a TRiDaS file - if(grepl("", l1)){ - cat(gettext("Detected a TRiDaS file.\n", - domain="R-dplR")) - close(f) - read.tridas(fname, ...) - } else { - ## may be preceded by an XML - ## declaration, comments, etc. Therefore, if - ## the first line did not contain , we - ## read a "reasonable number" of additional - ## lines, and try to detect in those. - more.lines <- readLines(f, n=20) - close(f) - if(any(grepl("", more.lines))){ - cat(gettext("Detected a TRiDaS file.\n", - domain="R-dplR")) - read.tridas(fname, ...) - } else { - cat(gettext("Assuming a Tucson format file.\n", - domain="R-dplR")) - read.tucson(fname, ...) - } - } + csv2rwl(fname, ...) + } + else { # Settle for tucson if none of the above pan out + cat(gettext("Assuming a Tucson format file.\n", + domain="R-dplR")) + read.tucson(fname, ...) + } } + } }, + tucson = read.tucson(fname, ...), compact = read.compact(fname, ...), + tridas = read.tridas(fname, ...), heidelberg = read.fh(fname, ...), - tridas = read.tridas(fname, ...), - tucson = read.tucson(fname, ...)) -} + csv = csv2rwl(fname, ...)) + } Added: pkg/dplR/man/csv2rwl.Rd =================================================================== --- pkg/dplR/man/csv2rwl.Rd (rev 0) +++ pkg/dplR/man/csv2rwl.Rd 2018-04-07 00:43:01 UTC (rev 1091) @@ -0,0 +1,50 @@ +\encoding{UTF-8} +\name{csv2rwl} +\alias{csv2rwl} +\title{ Read Ring Width File from CSV } +\description{ + This function reads in a file of ring widths (.rwl) from a text file with comma separated values (csv). +} +\usage{ +csv2rwl(fname,...) +} +\arguments{ + + \item{fname}{ a \code{character} vector giving the file name of the + csv file. } + + \item{\dots}{ other arguments passed to \code{\link{read.table}}. } +} +\details{ +This is a simple wrapper to \code{\link{read.table}} that reads in a text file with ring-width series in columns and the the years as rows. The file should have the first column contain the years and each subsequent column contain a series. The series names should be in the first row of the file. + +Note that this is a rudimentary convenience function that isn't doing anything sophisticated. It reads in a file, assigns the years to the row names and sets the class of the object to \code{c("rwl","data.frame")} which allows \code{dplR} to recognize it. + +Although arguments can be passed to \code{\link{read.table}}, this is not designed to be a flexible function. As is the philosophy with \code{dplR}, modifying the code is easy should the user wish to read in a different style of text file (e.g., tab delimited). Typing \code{csv2rwl} at the \code{R} prompt will get the user started. + +} +\value{ + Function returns an object of class + \code{c("rwl", "data.frame")} with the series in columns and the years + as rows. The series \acronym{ID}s are the column names and the years + are the row names. +} +\author{ Andy Bunn } +\seealso{ \code{\link{read.rwl}} } +\examples{ +library(utils) +data(ca533) +# write out a rwl file in a format that csv2rwl will understand +tm <- time(ca533) +foo <- data.frame(tm,ca533) +# this is the temp file where foo will be written +tmpName <- tempfile() +write.csv(foo,file=tmpName,row.names=FALSE) +# read it back in using csv2rwl +bar <- csv2rwl(tmpName) +# check to see if identical +identical(ca533,bar) +# delete temp file +unlink(tmpName) +} +\keyword{ IO } Property changes on: pkg/dplR/man/csv2rwl.Rd ___________________________________________________________________ Added: svn:eol-style + native Modified: pkg/dplR/man/read.rwl.Rd =================================================================== --- pkg/dplR/man/read.rwl.Rd 2018-04-06 04:48:45 UTC (rev 1090) +++ pkg/dplR/man/read.rwl.Rd 2018-04-07 00:43:01 UTC (rev 1091) @@ -8,7 +8,7 @@ } \usage{ read.rwl(fname, - format = c("auto", "tucson", "compact", "tridas", "heidelberg"), + format = c("auto", "tucson", "compact", "tridas", "heidelberg", "csv"), \dots) } \arguments{ @@ -17,9 +17,9 @@ rwl file. } \item{format}{ a \code{character} vector giving the format. This must - be \code{"auto"} (automatic detection), \code{"tucson"}, - \code{"compact"}, \code{"tridas"} or \code{"heidelberg"}. Automatic - format detection is the default. } + be \code{"auto"} (rough automatic detection), \code{"tucson"}, + \code{"compact"}, \code{"tridas"}, \code{"heidelberg"} or \code{"csv"}. Automatic + format detection is the default but failable. } \item{\dots}{ arguments specific to the function implementing the operation for the chosen format. } @@ -30,7 +30,7 @@ read operation. } \value{ - If a \code{"tucson"}, \code{"compact"} or \code{"heidelberg"} file is + If a \code{"tucson"}, \code{"compact"}, \code{"heidelberg"}, \code{"csv"} file is read (even through \code{"auto"}), returns an object of class \code{c("rwl", "data.frame")} with the series in columns and the years as rows. The series \acronym{ID}s are the column names and the years @@ -42,5 +42,6 @@ } \author{ Mikko Korpela } \seealso{ \code{\link{read.tucson}}, \code{\link{read.compact}}, - \code{\link{read.tridas}}, \code{\link{read.fh}}, \code{\link{write.rwl}} } + \code{\link{read.tridas}}, \code{\link{read.fh}}, \code{\link{csv2rwl}}, + \code{\link{write.rwl}} } \keyword{ IO } From noreply at r-forge.r-project.org Sat Apr 7 21:14:57 2018 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 7 Apr 2018 21:14:57 +0200 (CEST) Subject: [Dplr-commits] r1092 - in pkg/dplR: . vignettes Message-ID: <20180407191457.D2F5518936C@r-forge.r-project.org> Author: mvkorpel Date: 2018-04-07 21:14:57 +0200 (Sat, 07 Apr 2018) New Revision: 1092 Modified: pkg/dplR/ChangeLog pkg/dplR/DESCRIPTION pkg/dplR/vignettes/timeseries-dplR.Rnw Log: Dependency tweaks Modified: pkg/dplR/ChangeLog =================================================================== --- pkg/dplR/ChangeLog 2018-04-07 00:43:01 UTC (rev 1091) +++ pkg/dplR/ChangeLog 2018-04-07 19:14:57 UTC (rev 1092) @@ -2,6 +2,13 @@ - Note that Darwin Alexander Pucha Cofrep has been added as a developer to work on plotRings() etc. +File: DESCRIPTION +---------------- + +- Fixing the version requirement for "animation" (>= 2.0-2) +- Fixing the version requirement for "R.utils" (>= 1.32.1) +- Introducing version requirement (>= 3.6) for suggested package "forecast" + File: csv2rwl.R ---------------- Adding new function to read csv files in as rwl objects. Also adding that capability into read.rwl. Mikko should see if the error checks etc pass muster. Modified: pkg/dplR/DESCRIPTION =================================================================== --- pkg/dplR/DESCRIPTION 2018-04-07 00:43:01 UTC (rev 1091) +++ pkg/dplR/DESCRIPTION 2018-04-07 19:14:57 UTC (rev 1092) @@ -3,7 +3,7 @@ Type: Package Title: Dendrochronology Program Library in R Version: 1.6.8 -Date: 2018-04-05 +Date: 2018-04-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", "cph", "trl")), person("Franco", "Biondi", @@ -22,11 +22,11 @@ Depends: R (>= 2.15.2) Imports: graphics, grDevices, grid, stats, utils, lattice (>= 0.13-6), Matrix (>= 1.0-3), digest (>= 0.2.3), matrixStats (>= 0.50.2), - png (>= 0.1-2), R.utils (>= 1.32.0), stringi (>= 0.2-3), - stringr (>= 0.4), XML (>= 2.1-0), plyr (>= 1.8), - animation (>= 1.8) + png (>= 0.1-2), R.utils (>= 1.32.1), stringi (>= 0.2-3), + stringr (>= 0.4), XML (>= 2.1-0), plyr (>= 1.8), + animation (>= 2.0-2) Suggests: Biobase, Cairo (>= 1.5-0), dichromat (>= 1.2-3), foreach, - forecast, gmp (>= 0.5-5), iterators, knitr, RColorBrewer, + forecast (>= 3.6), gmp (>= 0.5-5), iterators, knitr, RColorBrewer, testthat (>= 0.8), tikzDevice, waveslim Description: Perform tree-ring analyses such as detrending, chronology building, and cross dating. Read and write standard file formats Modified: pkg/dplR/vignettes/timeseries-dplR.Rnw =================================================================== --- pkg/dplR/vignettes/timeseries-dplR.Rnw 2018-04-07 00:43:01 UTC (rev 1091) +++ pkg/dplR/vignettes/timeseries-dplR.Rnw 2018-04-07 19:14:57 UTC (rev 1092) @@ -159,13 +159,15 @@ \newif\ifforecastUsable% Define boolean variable <>= ## Test if forecast can be loaded -if (require("forecast", character.only = TRUE)) { +if (require("forecast", character.only = TRUE) && + packageVersion("forecast") >= "3.6") { cat("\\forecastUsabletrue\n\n")# output to LaTeX } @ \ifforecastUsable% Conditional: If "forecast" is available <<>>= -if (require("forecast", character.only = TRUE)) { +if (require("forecast", character.only = TRUE) && + packageVersion("forecast") >= "3.6") { dat.arima <- auto.arima(dat, ic="bic") summary(dat.arima) head(residuals(dat.arima)) @@ -179,7 +181,7 @@ (just the first few), model coefficients, etc. quite easily. And indeed the residuals are quite clean as we would expect. \else% If "forecast" is not available -An example was dropped because \code{"forecast"} is not available. +An example was dropped because \code{"forecast"} ($\geq 3.6$) is not available. \fi% End of conditional \section{Frequency Domain} There is, at times, an almost manic desire to better characterize the From noreply at r-forge.r-project.org Sat Apr 7 22:56:20 2018 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 7 Apr 2018 22:56:20 +0200 (CEST) Subject: [Dplr-commits] r1093 - in pkg/dplR: . R man Message-ID: <20180407205620.18AE61894C7@r-forge.r-project.org> Author: andybunn Date: 2018-04-07 22:56:19 +0200 (Sat, 07 Apr 2018) New Revision: 1093 Modified: pkg/dplR/ChangeLog pkg/dplR/R/plotRings.R pkg/dplR/man/csv2rwl.Rd Log: Small changes to pltRings and added text to help file for csv2rwl. Modified: pkg/dplR/ChangeLog =================================================================== --- pkg/dplR/ChangeLog 2018-04-07 19:14:57 UTC (rev 1092) +++ pkg/dplR/ChangeLog 2018-04-07 20:56:19 UTC (rev 1093) @@ -9,6 +9,11 @@ - Fixing the version requirement for "R.utils" (>= 1.32.1) - Introducing version requirement (>= 3.6) for suggested package "forecast" +File: plotRings.R +---------------- + +- Notes an issue in the length.unit arg to the function given differently in the Rd file vs the R file. Made a quick fix. Also made a small adjustment to the axis limits as it seemed there was a lot of extra white space in the plot. Removed bty for the legend. Not sure if I understand the full rationale behind the way the function is written though. -AGB + File: csv2rwl.R ---------------- Adding new function to read csv files in as rwl objects. Also adding that capability into read.rwl. Mikko should see if the error checks etc pass muster. Modified: pkg/dplR/R/plotRings.R =================================================================== --- pkg/dplR/R/plotRings.R 2018-04-07 19:14:57 UTC (rev 1092) +++ pkg/dplR/R/plotRings.R 2018-04-07 20:56:19 UTC (rev 1093) @@ -69,15 +69,15 @@ if(exists("x")==TRUE) TRW$E_W <- x # add to the TRW data.frame z <- TRW$trw.acc # accumulative rings - + # Getting and coloring the narrow and wider rings - q2 <- as.numeric(quantile(TRW[,5])[2]) # quantile 25% of trw.means - col.narrow.rings <- ifelse(TRW[,5] <= q2, col.x.rings, col.inrings) - q4 <- as.numeric(quantile(TRW[,5])[4]) # quantile 75% of trw.means - col.wider.rings <- ifelse(TRW[,5] >= q4, col.x.rings, col.inrings) + q2 <- as.numeric(quantile(TRW[,5])[2]) # quantile 25% of trw.means + col.narrow.rings <- ifelse(TRW[,5] <= q2, col.x.rings, col.inrings) + q4 <- as.numeric(quantile(TRW[,5])[4]) # quantile 75% of trw.means + col.wider.rings <- ifelse(TRW[,5] >= q4, col.x.rings, col.inrings) - + ## AREA calculation: pi(radius)^2 || pi(z)^2 # Acummulative BAI (inside out) @@ -85,115 +85,115 @@ # Individual BAI (inside out) TRW$bai.ind <-c(TRW$bai.acc[1], TRW$bai.acc[2:nrow(TRW)] - TRW$bai.acc[1:nrow(TRW)-1]) - # # # # # # # # # # # # # # # # # # # ## # # # # # # # # # # # # # # # # # # # + # # # # # # # # # # # # # # # # # # # ## # # # # # # # # # # # # # # # # # # # ## Plotting - if (animation == TRUE) { + if (animation == TRUE) { # With animation for (i in 1:length(x)) { # Rings - par(mar=c(1,4,1,1)+0.1) + par(mar=c(1,4,1,1)+0.1,xaxs="i",yaxs="i") cols <- c(rep(col.inrings, i-1), col.outring) narrow.cols <- c(col.narrow.rings[1:i-1], col.outring) # colors when is selected "narrow.rings" wider.cols <- c(col.wider.rings[1:i-1], col.outring) # colors when is selected "wider.rings" - - max.acc <- max(z, na.rm = TRUE) * 2.5 + + max.acc <- max(z, na.rm = TRUE) * 2.0 symbols(y = y[1:i], x = if(length(x) > 0) y[1:i] else x[1:i], - circles=z[1:i], inches=FALSE, xlim = c(-max.acc, max.acc), ylim = c(-max.acc, max.acc), - xlab='', ylab='Width [mm]', main=mtext(bquote(~bold(.("Annual tree growth"))), - line=1.5,adj=0.5, side=3, cex=1.5), - sub=if(!is.na(species.name)) mtext(bquote(~plain(.("(")) ~italic(.(species.name)) ~plain(.(")"))), - line=0.5,adj=0.5, side=3, cex=1), - fg= if(x.rings == "narrow.rings") narrow.cols - else if(x.rings == "wider.rings") wider.cols - else if(x.rings == "none") cols) + circles=z[1:i], inches=FALSE, xlim = c(-max.acc, max.acc), ylim = c(-max.acc, max.acc), + xlab='', ylab='Width [mm]', main=mtext(bquote(~bold(.("Annual tree growth"))), + line=1.5,adj=0.5, side=3, cex=1.5), + sub=if(!is.na(species.name)) mtext(bquote(~plain(.("(")) ~italic(.(species.name)) ~plain(.(")"))), + line=0.5,adj=0.5, side=3, cex=1), + fg= if(x.rings == "narrow.rings") narrow.cols + else if(x.rings == "wider.rings") wider.cols + else if(x.rings == "none") cols) # year labels - if(year.labels == TRUE) legend('topright', legend=year[i], box.lty=0, inset = 0.01, cex=2) + if(year.labels == TRUE) legend('topright', legend=year[i], bty="n", inset = 0.01, cex=2) Sys.sleep(sys.sleep) } } - # Without animation + # Without animation else { - par(mar=c(1,4,1,1)+0.1) + par(mar=c(1,4,1,1)+0.1,xaxs="i",yaxs="i") cols <- c(rep(col.inrings, length(x)-1), col.outring) narrow.cols <- c(col.narrow.rings[1:length(x)-1], col.outring) # colors when is selected "narrow.rings" wider.cols <- c(col.wider.rings[1:length(x)-1], col.outring) # colors when is selected "wider.rings" rings.lwd <- c(rep(1, length(x)), 3) - max.acc <- max(z, na.rm = TRUE) * 2.5 + max.acc <- max(z, na.rm = TRUE) * 2.0 symbols( y = y, x = if(length(x) > 0) y else x, circles=z, inches=FALSE, xlim = c(-max.acc, max.acc), ylim = c(-max.acc, max.acc), xlab='', ylab='Width [mm]', main=mtext(bquote(~bold(.("Annual tree growth"))), line=1.5,adj=0.5, - side=3, cex=1.5), sub= if(!is.na(species.name)) mtext(bquote(~plain(.("(")) ~italic(.(species.name)) ~plain(.(")"))), - line=0.5,adj=0.5, side=3, cex=1), + side=3, cex=1.5), sub= if(!is.na(species.name)) mtext(bquote(~plain(.("(")) ~italic(.(species.name)) ~plain(.(")"))), + line=0.5,adj=0.5, side=3, cex=1), fg= if(x.rings == "narrow.rings") narrow.cols else if(x.rings == "wider.rings") wider.cols else if(x.rings == "none") cols) - + # year labels - if(year.labels == TRUE) legend('topright', legend=paste(range(year)[1], "-", range(year)[2]), box.lty=0, inset = 0.01, cex=1.2) - } + if(year.labels == TRUE) legend('topright', legend=paste(range(year)[1], "-", range(year)[2]), bty="n", inset = 0.01, cex=1.2) + } # saveGIF - if (saveGIF == TRUE) { - - saveGIF({ - par (bg="white") - - # With animation - for (i in 1:length(x)) { - # Rings - par(mar=c(1,4,1,1)+0.1,cex=1.5) - cols <- c(rep(col.inrings, i-1), col.outring) - narrow.cols <- c(col.narrow.rings[1:i-1], col.outring) # colors when is selected "narrow.rings" - wider.cols <- c(col.wider.rings[1:i-1], col.outring) # colors when is selected "wider.rings" - - max.acc <- max(z, na.rm = TRUE) * 2.5 - symbols(y = y[1:i], x = if(length(x) > 0) y[1:i] else x[1:i], - circles=z[1:i], inches=FALSE, xlim = c(-max.acc, max.acc), ylim = c(-max.acc, max.acc), - xlab='', ylab='Width [mm]', main=mtext(bquote(~bold(.("Annual tree growth"))), - line=1.5,adj=0.5, side=3, cex=1.5), - sub=if(!is.na(species.name)) mtext(bquote(~plain(.("(")) ~italic(.(species.name)) ~plain(.(")"))), - line=0.5,adj=0.5, side=3, cex=1), + if (saveGIF == TRUE) { + + saveGIF({ + par(bg="white") + + # With animation + for (i in 1:length(x)) { + # Rings + par(mar=c(1,4,1,1)+0.1,cex=1.5,xaxs="i",yaxs="i") + cols <- c(rep(col.inrings, i-1), col.outring) + narrow.cols <- c(col.narrow.rings[1:i-1], col.outring) # colors when is selected "narrow.rings" + wider.cols <- c(col.wider.rings[1:i-1], col.outring) # colors when is selected "wider.rings" + + max.acc <- max(z, na.rm = TRUE) * 2.0 + symbols(y = y[1:i], x = if(length(x) > 0) y[1:i] else x[1:i], + circles=z[1:i], inches=FALSE, xlim = c(-max.acc, max.acc), ylim = c(-max.acc, max.acc), + xlab='', ylab='Width [mm]', main=mtext(bquote(~bold(.("Annual tree growth"))), + line=1.5,adj=0.5, side=3, cex=1.5), + sub=if(!is.na(species.name)) mtext(bquote(~plain(.("(")) ~italic(.(species.name)) ~plain(.(")"))), + line=0.5,adj=0.5, side=3, cex=1), + fg= if(x.rings == "narrow.rings") narrow.cols + else if(x.rings == "wider.rings") wider.cols + else if(x.rings == "none") cols) + + # year labels + if(year.labels == TRUE) legend('topright', legend=year[i], bty="n", inset = 0.01, cex=2) + } + }, movie.name = fname, interval = sys.sleep, nmax = 10, ani.width = 1000, + ani.height = 1000) + } + + # Without saving the GIF + else { + par(mar=c(1,4,1,1)+0.1,xaxs="i",yaxs="i") + cols <- c(rep(col.inrings, length(x)-1), col.outring) + narrow.cols <- c(col.narrow.rings[1:length(x)-1], col.outring) # colors when is selected "narrow.rings" + wider.cols <- c(col.wider.rings[1:length(x)-1], col.outring) # colors when is selected "wider.rings" + rings.lwd <- c(rep(1, length(x)), 3) + + max.acc <- max(z, na.rm = TRUE) * 2.0 + symbols( y = y, x = if(length(x) > 0) y else x, + circles=z, inches=FALSE, xlim = c(-max.acc, max.acc), ylim = c(-max.acc, max.acc), + xlab='', ylab='Width [mm]', main=mtext(bquote(~bold(.("Annual tree growth"))), line=1.5,adj=0.5, + side=3, cex=1.5), sub= if(!is.na(species.name)) mtext(bquote(~plain(.("(")) ~italic(.(species.name)) ~plain(.(")"))), + line=0.5,adj=0.5, side=3, cex=1), fg= if(x.rings == "narrow.rings") narrow.cols else if(x.rings == "wider.rings") wider.cols - else if(x.rings == "none") cols) - - # year labels - if(year.labels == TRUE) legend('topright', legend=year[i], box.lty=0, inset = 0.01, cex=2) - } - }, movie.name = fname, interval = sys.sleep, nmax = 10, ani.width = 1000, - ani.height = 1000) -} - - # Without saving the GIF - else { - par(mar=c(1,4,1,1)+0.1) - cols <- c(rep(col.inrings, length(x)-1), col.outring) - narrow.cols <- c(col.narrow.rings[1:length(x)-1], col.outring) # colors when is selected "narrow.rings" - wider.cols <- c(col.wider.rings[1:length(x)-1], col.outring) # colors when is selected "wider.rings" - rings.lwd <- c(rep(1, length(x)), 3) - - max.acc <- max(z, na.rm = TRUE) * 2.5 - symbols( y = y, x = if(length(x) > 0) y else x, - circles=z, inches=FALSE, xlim = c(-max.acc, max.acc), ylim = c(-max.acc, max.acc), - xlab='', ylab='Width [mm]', main=mtext(bquote(~bold(.("Annual tree growth"))), line=1.5,adj=0.5, - side=3, cex=1.5), sub= if(!is.na(species.name)) mtext(bquote(~plain(.("(")) ~italic(.(species.name)) ~plain(.(")"))), - line=0.5,adj=0.5, side=3, cex=1), - fg= if(x.rings == "narrow.rings") narrow.cols - else if(x.rings == "wider.rings") wider.cols - else if(x.rings == "none") cols) - - # year labels - if(year.labels == TRUE) legend('topright', legend=paste(range(year)[1], "-", range(year)[2]), box.lty=0, inset = 0.01, cex=1.2) - } - - + else if(x.rings == "none") cols) + + # year labels + if(year.labels == TRUE) legend('topright', legend=paste(range(year)[1], "-", range(year)[2]), bty="n", inset = 0.01, cex=1.2) + } + + ## Print Report: print("Output data:") # print(TRW) # all data.frame Modified: pkg/dplR/man/csv2rwl.Rd =================================================================== --- pkg/dplR/man/csv2rwl.Rd 2018-04-07 19:14:57 UTC (rev 1092) +++ pkg/dplR/man/csv2rwl.Rd 2018-04-07 20:56:19 UTC (rev 1093) @@ -16,7 +16,18 @@ \item{\dots}{ other arguments passed to \code{\link{read.table}}. } } \details{ -This is a simple wrapper to \code{\link{read.table}} that reads in a text file with ring-width series in columns and the the years as rows. The file should have the first column contain the years and each subsequent column contain a series. The series names should be in the first row of the file. +This is a simple wrapper to \code{\link{read.table}} that reads in a text file with ring-width data in "spreadsheet" format. I.e., with series in columns and the the years as rows. The first column should contain the years and each subsequent column should contain a tree-ring series. The series names should be in the first row of the file. The deafult for \code{\link{NA}} values are empty cells or as the character string \code{"NA"} but can also be set using the \code{na.strings} argument passed to \code{\link{read.table}}. E.g.,: +\tabular{lllll}{ +Year \tab Ser1A \tab Ser1B \tab Ser2A \tab Ser2B\cr +1901 \tab NA \tab 0.45 \tab 0.43 \tab 0.24\cr +1902 \tab NA \tab 0.05 \tab 0.00 \tab 0.07\cr +1903 \tab 0.17 \tab 0.46 \tab 0.03 \tab 0.21\cr +1904 \tab 0.28 \tab 0.21 \tab 0.54 \tab 0.41\cr +1905 \tab 0.29 \tab 0.85 \tab 0.17 \tab 0.76\cr +1906 \tab 0.56 \tab 0.64 \tab 0.56 \tab 0.31\cr +1907 \tab 1.12 \tab 1.06 \tab 0.99 \tab 0.83\cr +etc... +} Note that this is a rudimentary convenience function that isn't doing anything sophisticated. It reads in a file, assigns the years to the row names and sets the class of the object to \code{c("rwl","data.frame")} which allows \code{dplR} to recognize it. @@ -30,7 +41,7 @@ are the row names. } \author{ Andy Bunn } -\seealso{ \code{\link{read.rwl}} } +\seealso{ \code{\link{read.rwl}}, \code{\link{read.table}} } \examples{ library(utils) data(ca533)