[Dplr-commits] r1066 - in pkg/dplR: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed May 10 11:47:34 CEST 2017
Author: mvkorpel
Date: 2017-05-10 11:47:34 +0200 (Wed, 10 May 2017)
New Revision: 1066
Modified:
pkg/dplR/ChangeLog
pkg/dplR/DESCRIPTION
pkg/dplR/NAMESPACE
pkg/dplR/R/helpers.R
pkg/dplR/R/rasterPlot.R
pkg/dplR/R/redfit.R
pkg/dplR/man/redfit.Rd
Log:
"gmp" package is now optional.
Only affects redfit() and runcrit(), and even then in circumstances
which are not common (very long timeseries or non-default acceptance
levels), and even then only slightly (normal approximation of acceptance
region is very accurate). Additionally, argument 'p' cannot be of type
"bigq" if "gmp" is not installed.
Modified: pkg/dplR/ChangeLog
===================================================================
--- pkg/dplR/ChangeLog 2017-04-25 09:57:25 UTC (rev 1065)
+++ pkg/dplR/ChangeLog 2017-05-10 09:47:34 UTC (rev 1066)
@@ -8,6 +8,8 @@
- Added internal helper function check.tempdir()
+- Added internal helper function requireVersion()
+
File: latexify.R
----------------
@@ -27,6 +29,17 @@
- Check if temporary directory is missing before use
+File: redfit.R
+----------------
+
+- Computation of the exact acceptance region of number of runs
+ distributions in runcrit(), if not precomputed, depends on package
+ "gmp" being installed (now optional).
+
+- Argument 'p' of redfit() and runcrit() may be numeric (which is
+ the default) or "bigq", but the latter now fails if "gmp" is not
+ installed.
+
File: DESCRIPTION
----------------
@@ -49,6 +62,8 @@
- Technical change: Visibility of native routines has been
limited, following 6.15 "Controlling visibility" in R-exts.
+- Package "gmp" is now in Suggests, not in Imports.
+
File: sfrcs.R
----------------
Modified: pkg/dplR/DESCRIPTION
===================================================================
--- pkg/dplR/DESCRIPTION 2017-04-25 09:57:25 UTC (rev 1065)
+++ pkg/dplR/DESCRIPTION 2017-05-10 09:47:34 UTC (rev 1066)
@@ -3,7 +3,7 @@
Type: Package
Title: Dendrochronology Program Library in R
Version: 1.6.6
-Date: 2017-04-25
+Date: 2017-05-10
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",
@@ -19,13 +19,12 @@
Maintainer: Andy Bunn <andy.bunn at wwu.edu>
Depends: R (>= 2.15.2)
Imports: graphics, grDevices, grid, stats, utils, lattice (>= 0.13-6),
- Matrix (>= 1.0-3), digest (>= 0.2.3), gmp (>= 0.5-5),
- 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)
+ 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)
Suggests: Biobase, Cairo (>= 1.5-0), dichromat (>= 1.2-3), foreach,
- forecast, iterators, knitr, RColorBrewer, testthat (>= 0.8),
- tikzDevice, waveslim
+ forecast, 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
used in dendrochronology.
Modified: pkg/dplR/NAMESPACE
===================================================================
--- pkg/dplR/NAMESPACE 2017-04-25 09:57:25 UTC (rev 1065)
+++ pkg/dplR/NAMESPACE 2017-05-10 09:47:34 UTC (rev 1066)
@@ -4,8 +4,6 @@
importFrom(digest, digest)
-importFrom(gmp, as.bigq, as.bigz, chooseZ, is.bigq)
-
importFrom(grDevices, dev.hold, dev.flush, rainbow, dev.capabilities,
dev.cur, png, dev.off, dev.set, devAskNewPage, dev.capture)
Modified: pkg/dplR/R/helpers.R
===================================================================
--- pkg/dplR/R/helpers.R 2017-04-25 09:57:25 UTC (rev 1065)
+++ pkg/dplR/R/helpers.R 2017-05-10 09:47:34 UTC (rev 1066)
@@ -1,3 +1,8 @@
+requireVersion <- function(package, ver) {
+ requireNamespace(package, quietly = TRUE) &&
+ packageVersion(package) >= ver
+}
+
### Try to create directory named by tempdir() if it has gone missing
check.tempdir <- function() {
td <- tempdir()
Modified: pkg/dplR/R/rasterPlot.R
===================================================================
--- pkg/dplR/R/rasterPlot.R 2017-04-25 09:57:25 UTC (rev 1065)
+++ pkg/dplR/R/rasterPlot.R 2017-05-10 09:47:34 UTC (rev 1066)
@@ -16,8 +16,7 @@
fallback <- TRUE
for (k in 1:2) {
if (Cairo2) {
- if (requireNamespace("Cairo", quietly = TRUE) &&
- packageVersion("Cairo") >= "1.4-8") {
+ if (requireVersion("Cairo", "1.4-8")) {
caps <- Cairo::Cairo.capabilities()
if (isTRUE(as.vector(caps["raster"]))) {
fallback <- FALSE
Modified: pkg/dplR/R/redfit.R
===================================================================
--- pkg/dplR/R/redfit.R 2017-04-25 09:57:25 UTC (rev 1065)
+++ pkg/dplR/R/redfit.R 2017-05-10 09:47:34 UTC (rev 1066)
@@ -160,7 +160,9 @@
stopifnot(is.numeric(nsim), length(nsim) == 1, is.finite(nsim), nsim >= 1,
round(nsim) == nsim)
if (length(p) > 0) {
- stopifnot(is.numeric(p) || is.bigq(p), p > 0, p < 1)
+ stopifnot(is.numeric(p) ||
+ (requireVersion("gmp", "0.5-5") && gmp::is.bigq(p)))
+ stopifnot(p > 0, p < 1)
}
stopifnot(is.numeric(maxTime), length(maxTime) == 1, maxTime >= 0)
stopifnot(is.numeric(nLimit), length(nLimit) == 1, nLimit >= 0,
@@ -874,7 +876,7 @@
## dplR: Utility function.
redfitRunprobZ <- function(k, n) {
- invhalfpowM1 <- as.bigz(2)^(n - 1)
+ invhalfpowM1 <- gmp::as.bigz(2)^(n - 1)
if (k %% 2 == 0) {
## even number of runs
r <- k / 2
@@ -882,7 +884,7 @@
nn1 <- length(n1)
halfn1 <- nn1 %/% 2
if (nn1 %% 2 == 1) {
- probsum <- chooseZ(n1[halfn1 + 1] - 1, r - 1)
+ probsum <- gmp::chooseZ(n1[halfn1 + 1] - 1, r - 1)
probsum <- probsum * probsum
} else {
probsum <- 0
@@ -890,19 +892,19 @@
lown1 <- n1[seq_len(halfn1)]
if (length(lown1) > 0) {
lown2 <- n - lown1
- probsum <- probsum + 2 * sum(chooseZ(lown1 - 1, r - 1) *
- chooseZ(lown2 - 1, r - 1))
+ probsum <- probsum + 2 * sum(gmp::chooseZ(lown1 - 1, r - 1) *
+ gmp::chooseZ(lown2 - 1, r - 1))
}
probsum / invhalfpowM1
} else if (k == 1) {
## one run
- as.bigq(2)^(1 - n)
+ gmp::as.bigq(2)^(1 - n)
} else {
## odd number of runs
r <- (k - 1) / 2
n1 <- seq(from = r + 1, by = 1, to = n - r)
n2 <- n - n1
- probsum <- sum(chooseZ(n1 - 1, r) * chooseZ(n2 - 1, r - 1))
+ probsum <- sum(gmp::chooseZ(n1 - 1, r) * gmp::chooseZ(n2 - 1, r - 1))
probsum / invhalfpowM1
}
}
@@ -910,10 +912,10 @@
## dplR: Utility function.
redfitRuncsum <- function(n, crit, verbose = FALSE,
timelimit = Inf) {
- if (is.bigq(crit)) {
+ if (gmp::is.bigq(crit)) {
halfcrit <- crit / 2
} else {
- halfcrit <- as.bigq(crit, 2)
+ halfcrit <- gmp::as.bigq(crit, 2)
}
verbose2 <- isTRUE(verbose)
nn <- length(n)
@@ -926,16 +928,16 @@
halfn <- thisn %/% 2
oddn <- thisn %% 2
complength <- halfn + oddn
- tmpcsums <- as.bigq(rep.int(NA_real_, complength))
+ tmpcsums <- gmp::as.bigq(rep.int(NA_real_, complength))
if (oddn == 1) {
st <- system.time({
- csum <- (as.bigq(1) - redfitRunprobZ(complength,
- thisn)) / 2
+ csum <- (gmp::as.bigq(1) -
+ redfitRunprobZ(complength, thisn)) / 2
tmpcsums[[complength]] <- csum
})
} else {
st <- system.time({
- csum <- as.bigq(1, 2) - redfitRunprobZ(complength, thisn)
+ csum <- gmp::as.bigq(1, 2) - redfitRunprobZ(complength, thisn)
tmpcsums[[complength]] <- csum
})
}
@@ -959,7 +961,7 @@
seqstart <- max(2, finalk)
seqlength <- complength - seqstart + 1
## store n, drop 0 and NA
- csums[[j]] <- c(as.bigq(thisn),
+ csums[[j]] <- c(gmp::as.bigq(thisn),
tmpcsums[seq(from = seqstart, by = 1,
length.out = seqlength)])
}
@@ -1345,7 +1347,9 @@
## region of the number of runs test (p == 0.5). Exported function.
runcrit <- function(n, p = c(0.10, 0.05, 0.02), maxTime = 10, nLimit = 10000) {
if (length(p) > 0) {
- stopifnot(is.numeric(p) || is.bigq(p), p > 0, p < 1)
+ stopifnot(is.numeric(p) ||
+ (requireVersion("gmp", "0.5-5") && gmp::is.bigq(p)))
+ stopifnot(p > 0, p < 1)
}
stopifnot(is.numeric(n), length(n) == 1, n >= 1, round(n) == n)
stopifnot(is.numeric(maxTime), length(maxTime) == 1, maxTime >= 0)
@@ -1360,7 +1364,7 @@
todo <- colSums(is.na(rcritlohi)) > 0
if (any(todo)) {
## Exact solution by computation (n small enough)
- if (n < nLimit) {
+ if (n < nLimit && requireVersion("gmp", "0.5-5")) {
normCritMin <- normCrit[, which.min(p)]
## time allowed per "iteration"
maxTime2 <- maxTime /
Modified: pkg/dplR/man/redfit.Rd
===================================================================
--- pkg/dplR/man/redfit.Rd 2017-04-25 09:57:25 UTC (rev 1065)
+++ pkg/dplR/man/redfit.Rd 2017-05-10 09:47:34 UTC (rev 1066)
@@ -51,9 +51,10 @@
autocorrelation coefficient. If \code{NULL} or negative, the
autocorrelation coefficient will be estimated from the data. }
- \item{p}{ a \code{numeric} or \code{\link{bigq}} vector of
- significance levels for a statistical test considering the number of
- runs in a sequence. See \sQuote{Details}. }
+ \item{p}{ a \code{numeric} or \code{\link[gmp:bigrational]{bigq}} (if
+ package \code{"gmp"} is installed) vector of significance levels for
+ a statistical test considering the number of runs in a sequence.
+ See \sQuote{Details}. }
\item{iwin}{ the type of window used for scaling the values of each
segment of data. A \code{numeric} value or one of
@@ -151,8 +152,8 @@
some values of \code{\var{p}} and \code{\var{n}}. If a precomputed
result is not found and \code{\var{n}} is not too large
(\code{\var{nLimit}}, \code{\var{maxTime}}), the exact results are
- computed on-demand. Otherwise, the normal distribution is used for
- approximation.
+ computed on-demand. Otherwise, or if package \code{"gmp"} is not
+ installed, the normal distribution is used for approximation.
}
More information about the Dplr-commits
mailing list