[med-svn] [r-cran-scales] 01/03: Imported Upstream version 0.3.0

Andreas Tille tille at debian.org
Sat Dec 19 22:10:53 UTC 2015


This is an automated email from the git hooks/post-receive script.

tille pushed a commit to branch master
in repository r-cran-scales.

commit d6f97f0b221dffed7b07fa6addf47b5f2ba8230f
Author: Andreas Tille <tille at debian.org>
Date:   Sat Dec 19 20:56:25 2015 +0100

    Imported Upstream version 0.3.0
---
 DESCRIPTION                   |   6 ++--
 MD5                           |  67 ++++++++++++++++++++++--------------------
 NAMESPACE                     |  16 +++++++---
 NEWS                          |  12 +++++++-
 R/bounds.r                    |   6 ++--
 R/colour-manip.r              |  49 +++++++++++++++---------------
 R/colour-mapping.r            |  10 +++----
 R/date-time.r                 |   2 +-
 R/formatter.r                 |   6 ++--
 R/pal-brewer.r                |   4 +--
 R/pal-dichromat.r             |   2 +-
 R/pal-gradient.r              |  53 +++++++++++++++------------------
 R/pal-grey.r                  |   2 +-
 R/pal-hue.r                   |   2 +-
 R/scale-continuous.r          |  24 ++++++++-------
 R/scale-discrete.r            |  14 ++++++---
 R/scales.r                    |   4 ++-
 R/trans-date.r                |  22 +++++++-------
 R/trans.r                     |   2 +-
 README.md                     |   2 +-
 build/partial.rdb             | Bin 8433 -> 8447 bytes
 man/alpha.Rd                  |   2 +-
 man/brewer_pal.Rd             |   4 +--
 man/date_trans.Rd             |   4 +--
 man/dichromat_pal.Rd          |   2 +-
 man/div_gradient_pal.Rd       |  12 ++++----
 man/gradient_n_pal.Rd         |   4 +--
 man/rescale.Rd                |   2 +-
 man/seq_gradient_pal.Rd       |   6 ++--
 man/time_trans.Rd             |   4 +--
 man/train_continuous.Rd       |  17 +++++++++++
 man/train_discrete.Rd         |  19 ++++++++++++
 tests/testthat/test-alpha.r   |   4 +--
 tests/testthat/test-range.r   |  25 ----------------
 tests/testthat/test-rescale.R |   5 ++++
 tests/testthat/test-scale.r   |   2 +-
 36 files changed, 231 insertions(+), 186 deletions(-)

diff --git a/DESCRIPTION b/DESCRIPTION
index e8a3080..0f52d31 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,5 +1,5 @@
 Package: scales
-Version: 0.2.5
+Version: 0.3.0
 Authors at R: c(
     person("Hadley", "Wickham", , "hadley at rstudio.com", c("aut", "cre")),
     person("RStudio", role = "cph")
@@ -18,9 +18,9 @@ Suggests: testthat (>= 0.8)
 License: MIT + file LICENSE
 LazyLoad: yes
 NeedsCompilation: yes
-Packaged: 2015-06-12 16:14:42 UTC; hadley
+Packaged: 2015-08-24 18:41:17 UTC; hadley
 Author: Hadley Wickham [aut, cre],
   RStudio [cph]
 Maintainer: Hadley Wickham <hadley at rstudio.com>
 Repository: CRAN
-Date/Publication: 2015-06-12 23:50:17
+Date/Publication: 2015-08-25 00:48:31
diff --git a/MD5 b/MD5
index 1f4b24e..bc5e371 100644
--- a/MD5
+++ b/MD5
@@ -1,45 +1,45 @@
-29d506a30eaf011b43e8df38a4a2612d *DESCRIPTION
+7a912d5b194b30ffe629c909d88bd272 *DESCRIPTION
 42d91d5ce1f6db25d653397ec9da4f25 *LICENSE
-54fdd968f4485c3b22b764e0eb0acc5f *NAMESPACE
-9d77960b242dadc6010ba7eb83fd43ff *NEWS
+5c5ae3db358c91d8c1600359509074bf *NAMESPACE
+f8db5a3c861e1acb9043ba7ef50e43b7 *NEWS
 ee154387df2488852decb38c14e4c697 *R/RcppExports.R
-8b906c5c20e6f20d971485d94109892c *R/bounds.r
+b11eaa73b921a7f0ca0b9ce412d516c8 *R/bounds.r
 079b8af0d7acb058149e54824572af5a *R/breaks.r
-17252f5fd662f167ae903b92b49d1ddf *R/colour-manip.r
-6d5410196f7ed8aa9334fe7f837e04dd *R/colour-mapping.r
-d2c6598a250614e3ad4a5b47153d6b3e *R/date-time.r
+6c5942a0484c6b218a1c0b10405ac1cb *R/colour-manip.r
+4a57e7d2f12a3e7aa60e8e09b0a70f66 *R/colour-mapping.r
+2bfecd87cf7c8abc88ca53b3e1f1b31c *R/date-time.r
 f967c78e39bbcb23a60709f2a2735dbc *R/documentation.r
-6ebbb7185088f95f671ad1941dbdbca1 *R/formatter.r
+398bb391a0b6d275eccf60483364becf *R/formatter.r
 4f198007ee8d818bed5a007004f43e65 *R/full-seq.r
 932da2aa512e9fefe925ade14e87e30c *R/pal-area.r
-727241d5eb4b3abd11b9102a293927df *R/pal-brewer.r
-e3e27dccb6da5ed52478799e65843004 *R/pal-dichromat.r
-59192407795030694ff12bc1e31a2993 *R/pal-gradient.r
-71512f007a23dc9d24abcfed6361dad1 *R/pal-grey.r
-c20f4657f1ad2b33afffb0680ae0edcf *R/pal-hue.r
+4bef24eb3cd91584ceb428b48ea9b827 *R/pal-brewer.r
+1be098a7e018bb764be0c91e5b6dfaf5 *R/pal-dichromat.r
+8a1dde8a2ffb80b0e7937e9f3a299960 *R/pal-gradient.r
+ff822fc138fa2a4c20bf09b267b93215 *R/pal-grey.r
+458af3f9b86a6e4661a6e09ab33f4644 *R/pal-hue.r
 732494f5f4054ca39a7da7731d023add *R/pal-identity.r
 a4c1f8acacabe7943df7173df7fe0633 *R/pal-linetype.r
 716233051ba6990a7f9df54b51227294 *R/pal-manual.r
 8cf6ec1effbef4498ee7d88ce0cbe9e2 *R/pal-rescale.r
 58a8a345646e7034a6558e481defc8d6 *R/pal-shape.r
 6c4b15dde8f951ed9b35431756af8cb8 *R/range.r
-15e5251a1e5775a3b081728ac24cd207 *R/scale-continuous.r
-56da7559ee91befb22cc28f0c8fa4f55 *R/scale-discrete.r
-fc408b59519e0aa383e069d789484e95 *R/scales.r
-6f1a14588c52e2cfc70a4347c3b6a743 *R/trans-date.r
+0ab69e45b31579351cfe3ee1ea524380 *R/scale-continuous.r
+a3c1aeb6e357edf1b89db85eab5ef8e3 *R/scale-discrete.r
+9637a3d24c3c74a814043f55e6591fd9 *R/scales.r
+fc31d25bce46ab8166e6b21a7601622e *R/trans-date.r
 3f1ec156f1cb24f09643e4d02b68d393 *R/trans-numeric.r
-7f0e5368736657d377f6b1a77b6e8f84 *R/trans.r
-e64f23c90bdbf4d8827a62fc7225d54b *README.md
-228ae254b5cc635c4845872bc6bb6cbc *build/partial.rdb
+62abc8fd73c997d6e5e2312681b21086 *R/trans.r
+a9c0a08ac634745398cca9316fddd656 *README.md
+4b02916cf394c5bf6e9ca33112a651dc *build/partial.rdb
 fd70092adc19b48aa793fdb0f92dce1b *man/Range-class.Rd
 fce13530360aab377cc560559a4a2f93 *man/abs_area.Rd
-d258d45730e4128f57ee66209b889570 *man/alpha.Rd
+4c8d00f834a88a59389fa961167df75a *man/alpha.Rd
 d881492d8245940cfef56ccfb11d465f *man/area_pal.Rd
 c8e4c7d2827b05cb36a1d7d59f9232f4 *man/as.trans.Rd
 bb1bcadebad4c8fdf7f88ce0e2e68f89 *man/asn_trans.Rd
 72fc591d1cba0de07625bc2461e71c76 *man/atanh_trans.Rd
 780eddf013a39e7b8c5fe4f95e2bfeec *man/boxcox_trans.Rd
-c82c29f561c587a0176210fb70b972c5 *man/brewer_pal.Rd
+26081b6d8aec17644856bb53f6b5921f *man/brewer_pal.Rd
 eaf194b88f726dbc78adcb31e597e67d *man/cbreaks.Rd
 abe08ee28c8b500a428d99a15a6702de *man/censor.Rd
 057c32eec20053bba0ab8f4c3285587a *man/col2hcl.Rd
@@ -49,10 +49,10 @@ fa0983e358e9f4c6cf3404ea9e252aa6 *man/colour_ramp.Rd
 6af58fb0659e35ccd623578022b68229 *man/cscale.Rd
 d1184e9313cea106baeccbfb11972a97 *man/date_breaks.Rd
 e2ce34f86735e443653a822ad00be127 *man/date_format.Rd
-db2d1f498451ba63ae9246530a107dae *man/date_trans.Rd
-a45f6f2fbec9075e23a5949e898384bd *man/dichromat_pal.Rd
+ace144bb296e1cac3aa7a2361750f2f5 *man/date_trans.Rd
+3abed1cf8af5322670a540780cafc606 *man/dichromat_pal.Rd
 1d693820f56b36a92749acb1ef5c0c51 *man/discard.Rd
-ed3fcd5322e10fb47075dcb59e8a4379 *man/div_gradient_pal.Rd
+0fb84b7a30dc4c5e64951e840c754be2 *man/div_gradient_pal.Rd
 dd9f77b9581800966162dfcaf1bce214 *man/dollar_format.Rd
 aca55d1e3cf4a29a7587171c4c91f4f0 *man/dscale.Rd
 aefdfdcc999b84ae8baa165707006774 *man/exp_trans.Rd
@@ -60,7 +60,7 @@ aefdfdcc999b84ae8baa165707006774 *man/exp_trans.Rd
 fb25e4a8c9dfc63378e7e33e1e2dde13 *man/extended_breaks.Rd
 c4eb666dde93e1837eb23cfaafcdfb60 *man/format_format.Rd
 10107f4aeecf4630093b1f05b4c957c3 *man/fullseq.Rd
-f24fbbbfcb040fee0585509d77936e6c *man/gradient_n_pal.Rd
+1be5557586f0d6507909ba25d300f943 *man/gradient_n_pal.Rd
 51435e80a8cf16fc6f779641404b9301 *man/grey_pal.Rd
 2102643b3fbaf92689fa1e138c3c7911 *man/hue_pal.Rd
 e430a9cd1580ea10b2303dc73a024c56 *man/identity_pal.Rd
@@ -79,20 +79,22 @@ ddbfda0cf145475fcb278fd7cec04d5f *man/percent_format.Rd
 e163f69f11dd3b5ea25a7e43c25a15ba *man/pretty_breaks.Rd
 b6814d4a32eeff376cb0faf8fb85db16 *man/probability_trans.Rd
 76e2d86afd4307c610fcd741bab16ced *man/reciprocal_trans.Rd
-b87f012dbe9dbb60e6d3786716282a29 *man/rescale.Rd
+229bfc078c16f978d01178dd7f951d0e *man/rescale.Rd
 6b3ea9a1fc3c698b00520734008b0ec1 *man/rescale_max.Rd
 587a98fdf6437581b7794980eff7d80f *man/rescale_mid.Rd
 c9ba91efea5c79cd225cc2f891e98af9 *man/rescale_none.Rd
 f316dffe50d948ce165a3f70f6885b71 *man/rescale_pal.Rd
 580b26f89573ac7fb3dc59f2ca10339a *man/reverse_trans.Rd
 09c7e1d1e5b681b09e35b5389cb40e69 *man/scientific_format.Rd
-6c59838270e62d62548d9844fd0b3071 *man/seq_gradient_pal.Rd
+115a0b711054508faee683c6cd8ae722 *man/seq_gradient_pal.Rd
 b0bfb42b822b103e4247e723edd1244a *man/shape_pal.Rd
 e35211937f0d0333d7d8acf00884989d *man/show_col.Rd
 9b8a8077ed07e623fb1426a8be7148e8 *man/sqrt_trans.Rd
 3aae272f7d19655f21bf8ed3109d8a38 *man/squish.Rd
 cba1789efcb00599b2c60c34a9f7f423 *man/squish_infinite.Rd
-419b017f8806e229eabb09fcb33d7b3a *man/time_trans.Rd
+6a8cad78fb208a0835db9b7fc14b2825 *man/time_trans.Rd
+5ca5329c44b25166f9047bbfb03448d0 *man/train_continuous.Rd
+b50430a4a6c253f3710c6f5510dd1d11 *man/train_discrete.Rd
 e2f975db54c837882e145854cbd70430 *man/trans_breaks.Rd
 7fef205b9dcd4e613cb4f8c00bf8ec92 *man/trans_format.Rd
 df03a130e2e2a562cf936c6fe36815f6 *man/trans_new.Rd
@@ -103,13 +105,14 @@ dbf6561109775b98018a4eb99a4b5aff *man/wrap_format.Rd
 26153fe9ba8cc9c1db5c380f9b68ddd6 *src/RcppExports.cpp
 a6352bdbb8fc2eec47d3bd78ae92cb8d *src/colors.cpp
 1bc97669868c55fc86b10bffb2010b63 *tests/testthat.R
-41879206aab0f820a4262399a9357faf *tests/testthat/test-alpha.r
+9b1f7ff67006d13e255f222feba5ee9e *tests/testthat/test-alpha.r
 210d4b72f91809cb8c82a36d60eff279 *tests/testthat/test-bounds.r
 b5bb7a6051319394602be12701d8b845 *tests/testthat/test-breaks-log.r
 361eca6c9ef2ec2361364c81ff4a39cc *tests/testthat/test-colors.r
 654894086b182f8a53ecd56ba01e03cc *tests/testthat/test-formatter.r
-306be4c95033a6b3d1446644165026eb *tests/testthat/test-range.r
-1f4791748d113fc5cf34c84c7325348c *tests/testthat/test-scale.r
+0d20e9d3700f281822fcb193c9b5353d *tests/testthat/test-range.r
+61f4a2eb83089e04f6002733d904f909 *tests/testthat/test-rescale.R
+13dc6039e6126c6c5b837b69fdcca1be *tests/testthat/test-scale.r
 cf896ab44315aa38f0b00484b3e3c624 *tests/testthat/test-trans-date.r
 13c44729a8f80c2a38ed1be41a85b42c *tests/testthat/test-trans.r
 f898ccce2009062bb08a27f5e68d4eb0 *tests/testthat/test-zero-range.r
diff --git a/NAMESPACE b/NAMESPACE
index 9e1c4e4..594605e 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -79,6 +79,8 @@ export(sqrt_trans)
 export(squish)
 export(squish_infinite)
 export(time_trans)
+export(train_continuous)
+export(train_discrete)
 export(trans_breaks)
 export(trans_format)
 export(trans_new)
@@ -86,8 +88,14 @@ export(trans_range)
 export(unit_format)
 export(wrap_format)
 export(zero_range)
-import(Rcpp)
-import(methods)
-import(munsell)
-import(plyr)
+importFrom(Rcpp,evalCpp)
+importFrom(graphics,par)
+importFrom(graphics,plot)
+importFrom(graphics,rect)
+importFrom(graphics,text)
+importFrom(methods,new)
+importFrom(methods,setRefClass)
+importFrom(munsell,mnsl)
+importFrom(plyr,is.discrete)
+importFrom(plyr,round_any)
 useDynLib(scales)
diff --git a/NEWS b/NEWS
index 4d7aba0..e570280 100644
--- a/NEWS
+++ b/NEWS
@@ -1,9 +1,19 @@
+Version 0.3.0
+------------------------------------------------------------------------------
+
+* `rescale()` preserves missing values in input when the range of `x` is
+  (effectively) 0 (ggplot2#985).
+
+* Continuous colour palettes now use `colour_ramp()` instead of `colorRamp()`.
+  This only supports interpolation in Lab colour space, but is hundreds of
+  times faster.
+
 Version 0.2.5
 ------------------------------------------------------------------------------
 
 ## Improved formatting functions
 
-* `date_format()` gans an option to specify time zone (#51).
+* `date_format()` gains an option to specify time zone (#51).
 
 * `dollar_format()` is now more flexible and can add either prefixes or suffixes
   for different currencies (#53). It gains a `negative_parens` argument
diff --git a/R/bounds.r b/R/bounds.r
index f8c22b5..5407f08 100644
--- a/R/bounds.r
+++ b/R/bounds.r
@@ -10,8 +10,10 @@
 #' rescale(1:100)
 #' rescale(runif(50))
 #' rescale(1)
-rescale <- function(x, to = c(0, 1), from = range(x, na.rm = TRUE)) {
-  if (zero_range(from) || zero_range(to)) return(rep(mean(to), length(x)))
+rescale <- function(x, to = c(0, 1), from = range(x, na.rm = TRUE, finite = TRUE)) {
+  if (zero_range(from) || zero_range(to)) {
+    return(ifelse(is.na(x), NA, mean(to)))
+  }
 
   (x - from[1]) / diff(from) * diff(to) + to[1]
 }
diff --git a/R/colour-manip.r b/R/colour-manip.r
index 241f2d2..d8ef411 100644
--- a/R/colour-manip.r
+++ b/R/colour-manip.r
@@ -9,27 +9,27 @@
 #' @param c new chroma
 #' @param alpha alpha value.  Defaults to 1.
 #' @export
-#' @examples 
+#' @examples
 #' col2hcl(colors())
 col2hcl <- function(colour, h, c, l, alpha = 1) {
-  
-  rgb <- t(col2rgb(colour)) / 255
-  coords <- convertColor(rgb, "sRGB", "Luv")
+
+  rgb <- t(grDevices::col2rgb(colour)) / 255
+  coords <- grDevices::convertColor(rgb, "sRGB", "Luv")
 
   # Check for correctness
   # colorspace::coords(as(RGB(rgb), "polarLUV"))
-  
+
   if (missing(h)) h <- atan2(coords[, "v"], coords[, "u"]) * 180 / pi
   if (missing(c)) c <- sqrt(coords[, "u"]^ 2 + coords[, "v"]^2)
   if (missing(l)) l <- coords[, "L"]
-    
-  hcl_colours <- hcl(h, c, l, alpha = alpha) 
-  names(hcl_colours) <- names(colour) 
+
+  hcl_colours <- grDevices::hcl(h, c, l, alpha = alpha)
+  names(hcl_colours) <- names(colour)
   hcl_colours
 }
 
 #' Mute standard colour.
-#' 
+#'
 #' @param colour character vector of colours to modify
 #' @param l new luminance
 #' @param c new chroma
@@ -42,60 +42,61 @@ muted <- function(colour, l=30, c=70) col2hcl(colour, l=l, c=c)
 
 #' Modify colour transparency.
 #' Vectorised in both colour and alpha.
-#' 
+#'
 #' @param colour colour
-#' @param alpha new alpha level in [0,1].  If alpha is \code{NA}, 
+#' @param alpha new alpha level in [0,1].  If alpha is \code{NA},
 #'   existing alpha values are preserved.
 #' @export
 #' @examples
 #' alpha("red", 0.1)
 #' alpha(colours(), 0.5)
-#' alpha("red", seq(0, 1, length = 10))
+#' alpha("red", seq(0, 1, length.out = 10))
 alpha <- function(colour, alpha = NA) {
-  col <- col2rgb(colour, TRUE) / 255
-  
+  col <- grDevices::col2rgb(colour, TRUE) / 255
+
   if (length(colour) != length(alpha)) {
     if (length(colour) > 1 && length(alpha) > 1) {
       stop("Only one of colour and alpha can be vectorised")
     }
-    
+
     if (length(colour) > 1) {
-      alpha <- rep(alpha, length.out = length(colour))    
+      alpha <- rep(alpha, length.out = length(colour))
     } else if (length(alpha) > 1) {
       col <- col[, rep(1, length(alpha)), drop = FALSE]
-    }    
+    }
   }
   alpha[is.na(alpha)] <- col[4, ][is.na(alpha)]
 
-  new_col <- rgb(col[1,], col[2,], col[3,], alpha)
-  new_col[is.na(colour)] <- NA  
+  new_col <- grDevices::rgb(col[1,], col[2,], col[3,], alpha)
+  new_col[is.na(colour)] <- NA
   new_col
 }
 
 #' Show colours.
-#' 
+#'
 #' A quick and dirty way to show colours in a plot.
 #'
 #' @param colours a character vector of colours
 #' @param labels boolean, whether to show the hexadecimal representation of the colours in each tile
 #' @param borders colour of the borders of the tiles; matches the \code{border} argument of \code{\link[graphics]{rect}}. The default means \code{par("fg")}. Use \code{border = NA} to omit borders.
 #' @export
+#' @importFrom graphics par plot rect text
 show_col <- function(colours, labels = TRUE, borders = NULL) {
   n <- length(colours)
   ncol <- ceiling(sqrt(n))
   nrow <- ceiling(n / ncol)
-  
+
   colours <- c(colours, rep(NA, nrow * ncol - length(colours)))
   colours <- matrix(colours, ncol = ncol, byrow = TRUE)
-  
+
   old <- par(pty = "s", mar = c(0, 0, 0, 0))
   on.exit(par(old))
-  
+
   size <- max(dim(colours))
   plot(c(0, size), c(0, -size), type = "n", xlab="", ylab="", axes = FALSE)
   rect(col(colours) - 1, -row(colours) + 1, col(colours), -row(colours),
     col = colours, border = borders)
   if ( labels ) {
-    text(col(colours) - 0.5, -row(colours) + 0.5, colours)    
+    text(col(colours) - 0.5, -row(colours) + 0.5, colours)
   }
 }
diff --git a/R/colour-mapping.r b/R/colour-mapping.r
index 46e3c39..a58dab5 100644
--- a/R/colour-mapping.r
+++ b/R/colour-mapping.r
@@ -130,7 +130,7 @@ col_quantile <- function(palette, domain, n = 4,
   probs = seq(0, 1, length.out = n + 1), na.color = "#808080") {
 
   if (!is.null(domain)) {
-    bins <- quantile(domain, probs, na.rm = TRUE, names = FALSE)
+    bins <- stats::quantile(domain, probs, na.rm = TRUE, names = FALSE)
     return(withColorAttr(
       'quantile', list(probs = probs, na.color = na.color),
       col_bin(palette, domain = NULL, bins = bins, na.color = na.color)
@@ -142,7 +142,7 @@ col_quantile <- function(palette, domain, n = 4,
   # or 5? 4, right?
   colorFunc <- col_factor(palette, domain = 1:(length(probs) - 1), na.color = na.color)
   withColorAttr('quantile', list(probs = probs, na.color = na.color), function(x) {
-    binsToUse <- quantile(x, probs, na.rm = TRUE, names = FALSE)
+    binsToUse <- stats::quantile(x, probs, na.rm = TRUE, names = FALSE)
     ints <- cut(x, binsToUse, labels = FALSE, include.lowest = TRUE, right = FALSE)
     if (any(is.na(x) != is.na(ints)))
       warning("Some values were outside the color scale and will be treated as NA")
@@ -287,7 +287,7 @@ toPaletteFunc.character <- function(pal) {
 
 # Accept colorRamp style matrix
 toPaletteFunc.matrix <- function(pal) {
-  toPaletteFunc(rgb(pal, maxColorValue = 255))
+  toPaletteFunc(grDevices::rgb(pal, maxColorValue = 255))
 }
 
 # If a function, just assume it's already a function over [0-1]
@@ -328,7 +328,7 @@ filterRGB <- function(f) {
     if (is.character(results)) {
       results
     } else if (is.matrix(results)) {
-      rgb(results, maxColorValue = 255)
+      grDevices::rgb(results, maxColorValue = 255)
     } else {
       stop("Unexpected result type ", class(x)[[1]])
     }
@@ -376,7 +376,7 @@ colour_ramp <- function(colors, na.color = NA, alpha = FALSE) {
     stop("Must provide at least one color to create a color ramp")
   }
 
-  colorMatrix <- col2rgb(colors, alpha = alpha)
+  colorMatrix <- grDevices::col2rgb(colors, alpha = alpha)
   structure(
     function(x) {
       doColorRamp(colorMatrix, x, alpha, ifelse(is.na(na.color), "", na.color))
diff --git a/R/date-time.r b/R/date-time.r
index 027f6d8..8dc266d 100644
--- a/R/date-time.r
+++ b/R/date-time.r
@@ -27,7 +27,7 @@ floor_time <- function(date, time) {
   } else {
     as.POSIXct(
       cut(date, time, right = TRUE, include.lowest = TRUE),
-      tz = attr(date, "tz") %||% ""
+      tz = attr(date, "tzone", exact = TRUE) %||% ""
     )
   }
 }
diff --git a/R/formatter.r b/R/formatter.r
index 1ee28ab..021f4cd 100644
--- a/R/formatter.r
+++ b/R/formatter.r
@@ -174,7 +174,7 @@ ordinal <- function(x) {
     th = "[0456789]$"
   )
 
-  out <- stack(llply(suffixes, grep, x = x, perl = TRUE))
+  out <- utils::stack(lapply(suffixes, grep, x = x, perl = TRUE))
   paste0(comma(x), out$ind[order(out$values)])
 }
 
@@ -188,7 +188,7 @@ ordinal <- function(x) {
 #' parse_format()(c("alpha", "beta", "gamma"))
 parse_format <- function() {
   function(x) {
-    llply(as.character(x), function(x) parse(text = x, srcfile = NULL))
+    lapply(as.character(x), function(x) parse(text = x, srcfile = NULL))
   }
 }
 
@@ -216,7 +216,7 @@ math_format <- function(expr = 10 ^ .x, format = force) {
 
   function(x) {
     x <- format(x)
-    llply(x, subs)
+    lapply(x, subs)
   }
 }
 globalVariables(".x")
diff --git a/R/pal-brewer.r b/R/pal-brewer.r
index 325a339..7b28b2f 100644
--- a/R/pal-brewer.r
+++ b/R/pal-brewer.r
@@ -11,11 +11,11 @@
 #' @examples
 #' show_col(brewer_pal()(10))
 #' show_col(brewer_pal("div")(5))
-#' show_col(brewer_pal(pal = "Greens")(5))
+#' show_col(brewer_pal(palette = "Greens")(5))
 #'
 #' # Can use with gradient_n to create a continous gradient
 #' cols <- brewer_pal("div")(5)
-#' show_col(gradient_n_pal(cols)(seq(0, 1, length = 30)))
+#' show_col(gradient_n_pal(cols)(seq(0, 1, length.out = 30)))
 brewer_pal <- function(type = "seq", palette = 1, direction = 1) {
   pal <- pal_name(palette, type)
 
diff --git a/R/pal-dichromat.r b/R/pal-dichromat.r
index 706aac9..b7c5524 100644
--- a/R/pal-dichromat.r
+++ b/R/pal-dichromat.r
@@ -9,7 +9,7 @@
 #'
 #' # Can use with gradient_n to create a continous gradient
 #' cols <- dichromat_pal("DarkRedtoBlue.12")(12)
-#' show_col(gradient_n_pal(cols)(seq(0, 1, length = 30)))
+#' show_col(gradient_n_pal(cols)(seq(0, 1, length.out = 30)))
 dichromat_pal <- function(name) {
   if (!any(name == names(dichromat::colorschemes))) {
     stop("Palette name must be one of ",
diff --git a/R/pal-gradient.r b/R/pal-gradient.r
index da60ab4..6e5f2f8 100644
--- a/R/pal-gradient.r
+++ b/R/pal-gradient.r
@@ -1,69 +1,62 @@
 #' Arbitrary colour gradient palette (continous).
-#' 
+#'
 #' @param colours vector of colours
 #' @param values if colours should not be evenly positioned along the gradient
 #'   this vector gives the position (between 0 and 1) for each colour in the
 #'   \code{colours} vector. See \code{\link{rescale}} for a convience function
 #'   to map an arbitrary range to between 0 and 1.
-#' @param space colour space in which to calculate gradient.  "Lab" usually
-#'   best unless gradient goes through white. 
+#' @param space colour space in which to calculate gradient. Must be "Lab" -
+#'   other values are deprecated.
 #' @export
 gradient_n_pal <- function(colours, values = NULL, space = "Lab") {
-  ramp <- colorRamp(colours, space = space)
+  if (!identical(space, "Lab")) {
+    warning("Non Lab interpolation is deprecated", call. = FALSE)
+  }
+  ramp <- colour_ramp(colours)
 
   function(x) {
     if (length(x) == 0) return(character())
-    
+
     if (!is.null(values)) {
-      xs <- seq(0, 1, length = length(values))      
-      f <- approxfun(values, xs)
+      xs <- seq(0, 1, length.out = length(values))
+      f <- stats::approxfun(values, xs)
       x <- f(x)
     }
-    
-    nice_rgb(ramp(x))
-  }
-}
 
-nice_rgb <- function(x) {
-  missing <- !complete.cases(x)
-  x[missing, ] <- 0
-
-  col <- rgb(x, maxColorValue = 255)
-  col[missing] <- NA
-  col
+    ramp(x)
+  }
 }
 
 #' Diverging colour gradient (continous).
-#' 
+#'
 #' @param low colour for low end of gradient.
 #' @param mid colour for mid point
 #' @param high colour for high end of gradient.
-#' @param space colour space in which to calculate gradient.  "Lab" usually
-#'   best unless gradient goes through white. 
+#' @inheritParams gradient_n_pal
 #' @export
 #' @examples
-#' x <- seq(-1, 1, length = 100)
+#' x <- seq(-1, 1, length.out = 100)
 #' r <- sqrt(outer(x^2, x^2, "+"))
-#' image(r, col = div_gradient_pal()(seq(0, 1, length = 12)))
-#' image(r, col = div_gradient_pal()(seq(0, 1, length = 30)))
-#' image(r, col = div_gradient_pal()(seq(0, 1, length = 100)))
+#' image(r, col = div_gradient_pal()(seq(0, 1, length.out = 12)))
+#' image(r, col = div_gradient_pal()(seq(0, 1, length.out = 30)))
+#' image(r, col = div_gradient_pal()(seq(0, 1, length.out = 100)))
 #'
 #' library(munsell)
-#' image(r, col = div_gradient_pal(low = 
+#' image(r, col = div_gradient_pal(low =
 #'    mnsl(complement("10R 4/6", fix = TRUE)))(seq(0, 1, length = 100)))
+#' @importFrom munsell mnsl
 div_gradient_pal <- function(low = mnsl("10B 4/6"), mid = mnsl("N 8/0"), high = mnsl("10R 4/6"), space = "Lab") {
   gradient_n_pal(c(low, mid, high), space = space)
 }
 
 #' Sequential colour gradient palette (continous).
-#' 
+#'
 #' @param low colour for low end of gradient.
 #' @param high colour for high end of gradient.
-#' @param space colour space in which to calculate gradient.  "Lab" usually
-#'   best unless gradient goes through white. 
+#' @inheritParams gradient_n_pal
 #' @export
 #' @examples
-#' x <- seq(0, 1, length = 25)
+#' x <- seq(0, 1, length.out = 25)
 #' show_col(seq_gradient_pal()(x))
 #' show_col(seq_gradient_pal("white", "black")(x))
 #'
diff --git a/R/pal-grey.r b/R/pal-grey.r
index 4743e71..fc5f18e 100644
--- a/R/pal-grey.r
+++ b/R/pal-grey.r
@@ -8,5 +8,5 @@
 #' show_col(grey_pal()(25))
 #' show_col(grey_pal(0, 1)(25))
 grey_pal <- function(start = 0.2, end = 0.8) {
-  function(n) grey.colors(n, start = start, end = end)
+  function(n) grDevices::grey.colors(n, start = start, end = end)
 }
diff --git a/R/pal-hue.r b/R/pal-hue.r
index 8afd14a..3c72d66 100644
--- a/R/pal-hue.r
+++ b/R/pal-hue.r
@@ -30,7 +30,7 @@ hue_pal <- function(h = c(0, 360) + 15, c = 100, l = 65, h.start = 0, direction
     }
 
     rotate <- function(x) (x + h.start) %% 360 * direction
-    hues <- rotate(seq(h[1], h[2], length = n))
+    hues <- rotate(seq(h[1], h[2], length.out = n))
 
     grDevices::hcl(hues, c, l)
   }
diff --git a/R/scale-continuous.r b/R/scale-continuous.r
index 70d39ce..f7941c5 100644
--- a/R/scale-continuous.r
+++ b/R/scale-continuous.r
@@ -1,36 +1,40 @@
 #' Continuous scale.
 #'
 #' @param x vector of continuous values to scale
-#' @param palette palette to use. 
-#' 
+#' @param palette palette to use.
+#'
 #'   Built in palettes:
 #'   \Sexpr[results=rd,stage=build]{scales:::seealso_pal()}
 #' @param na.value value to use for missing values
 #' @param trans transformation object describing the how to transform the
 #'  raw data prior to scaling.  Defaults to the identity transformation which
-#'  leaves the data unchanged. 
-#'  
+#'  leaves the data unchanged.
+#'
 #'  Built in transformations:
 #'  \Sexpr[results=rd,stage=build]{scales:::seealso_trans()}.
 #' @export
 #' @examples
 #' with(mtcars, plot(disp, mpg, cex = cscale(hp, rescale_pal())))
-#' with(mtcars, plot(disp, mpg, cex = cscale(hp, rescale_pal(), 
+#' with(mtcars, plot(disp, mpg, cex = cscale(hp, rescale_pal(),
 #'   trans = sqrt_trans())))
 #' with(mtcars, plot(disp, mpg, cex = cscale(hp, area_pal())))
-#' with(mtcars, plot(disp, mpg, pch = 20, cex = 5, 
+#' with(mtcars, plot(disp, mpg, pch = 20, cex = 5,
 #'   col = cscale(hp, seq_gradient_pal("grey80", "black"))))
 cscale <- function(x, palette, na.value = NA_real_, trans = identity_trans()) {
   stopifnot(is.trans(trans))
-  
-  x <- trans$trans(x)
+
+  x <- trans$transform(x)
   limits <- train_continuous(x)
   map_continuous(palette, x, limits, na.value)
 }
 
+#' Train (update) a continuous scale
+#'
+#' @inheritParams train_discrete
+#' @export
 train_continuous <- function(new, existing = NULL) {
   if (is.null(new)) return(existing)
-  
+
   if (!is.numeric(new)) {
     stop("Discrete value supplied to continuous scale",  call. = FALSE)
   }
@@ -38,7 +42,7 @@ train_continuous <- function(new, existing = NULL) {
 }
 
 # Map values for a continuous palette.
-# 
+#
 # @param oob out of bounds behaviour. Defaults to \code{\link{censor}}
 #   which turns oob values into missing values.
 map_continuous <- function(palette, x, limits, na.value = NA_real_, oob = censor) {
diff --git a/R/scale-discrete.r b/R/scale-discrete.r
index a1b8e58..99cc0e7 100644
--- a/R/scale-discrete.r
+++ b/R/scale-discrete.r
@@ -12,11 +12,17 @@ dscale <- function(x, palette, na.value = NA) {
   map_discrete(palette, x, limits, na.value)
 }
 
+#' Train (update) a discrete scale
+#'
+#' @param new New data to add to scale
+#' @param existing Optional existing scale to update
+#' @param drop \code{TRUE}, will drop factor levels not associated with data
+#' @export
 train_discrete <- function(new, existing = NULL, drop = FALSE) {
   if (is.null(new)) return(existing)
 
   if (!is.discrete(new)) {
-    stop("Continuous value supplied to discrete scale", call. = FALSE) 
+    stop("Continuous value supplied to discrete scale", call. = FALSE)
   }
   discrete_range(existing, new, drop = drop)
 }
@@ -27,12 +33,12 @@ discrete_range <- function(old, new, drop = FALSE) {
   if (!is.character(old)) old <- clevels(old)
 
   new_levels <- setdiff(new, as.character(old))
-  
+
   # Keep as a factor if we don't have any new levels
   if (length(new_levels) == 0) {
     return(old)
   }
-  
+
   sort(c(old, new_levels))
 }
 
@@ -44,7 +50,7 @@ clevels <- function(x, drop = FALSE) {
 
     values <- levels(x)
     if (any(is.na(x))) values <- c(values, NA)
-    
+
     values
   } else {
     sort(unique(x))
diff --git a/R/scales.r b/R/scales.r
index 48a9a93..a6961e5 100644
--- a/R/scales.r
+++ b/R/scales.r
@@ -3,6 +3,8 @@
 #' @docType package
 #' @name package-scales
 #' @aliases scales package-scales
-#' @import munsell plyr Rcpp methods
 #' @useDynLib scales
+#' @importFrom methods setRefClass new
+#' @importFrom plyr round_any is.discrete
+#' @importFrom Rcpp evalCpp
 NULL
diff --git a/R/trans-date.r b/R/trans-date.r
index 9dd0fe6..1fd9c35 100644
--- a/R/trans-date.r
+++ b/R/trans-date.r
@@ -4,8 +4,8 @@
 #' @examples
 #' years <- seq(as.Date("1910/1/1"), as.Date("1999/1/1"), "years")
 #' t <- date_trans()
-#' t$trans(years)
-#' t$inv(t$trans(years))
+#' t$transform(years)
+#' t$inverse(t$transform(years))
 #' t$format(t$breaks(range(years)))
 date_trans <- function() {
   trans_new("date", "from_date", "to_date", breaks = pretty_breaks())
@@ -28,19 +28,19 @@ from_date <- function(x) {
 #' @examples
 #' hours <- seq(ISOdate(2000,3,20, tz = ""), by = "hour", length.out = 10)
 #' t <- time_trans()
-#' t$trans(hours)
-#' t$inv(t$trans(hours))
+#' t$transform(hours)
+#' t$inverse(t$transform(hours))
 #' t$format(t$breaks(range(hours)))
 time_trans <- function(tz = NULL) {
-  
+
   to_time <- function(x) {
     force(x)
     structure(x, class = c("POSIXt", "POSIXct"), tzone = tz)
   }
-  
+
   from_time <- function(x) {
     if (!inherits(x, "POSIXct")) {
-      stop("Invalid input: time_trans works with objects of class ", 
+      stop("Invalid input: time_trans works with objects of class ",
         "POSIXct only", call. = FALSE)
     }
     if (is.null(tz)) {
@@ -48,16 +48,16 @@ time_trans <- function(tz = NULL) {
     }
     structure(as.numeric(x), names = names(x))
   }
-  
+
   trans_new("time", "from_time", "to_time", breaks = pretty_breaks())
 }
 
 
 #' Regularly spaced dates.
-#' 
+#'
 #' @param width an interval specification, one of "sec", "min", "hour",
 #'   "day", "week", "month", "year". Can be by an integer and a space, or
-#'   followed by "s". 
+#'   followed by "s".
 #' @export
 date_breaks <- function(width = "1 month") {
   function(x) fullseq(x, width)
@@ -65,7 +65,7 @@ date_breaks <- function(width = "1 month") {
 
 
 #' Formatted dates.
-#' 
+#'
 #' @param format Date format using standard POSIX specification.  See
 #'  \code{\link{strptime}} for possible formats.
 #' @param tz a time zone name, see \code{\link{timezones}}. Defaults
diff --git a/R/trans.r b/R/trans.r
index 0cad808..8d6354d 100644
--- a/R/trans.r
+++ b/R/trans.r
@@ -56,5 +56,5 @@ as.trans <- function(x) {
 #' @export
 trans_range <- function(trans, x) {
   trans <- as.trans(trans)
-  range(trans$trans(range(squish(x, trans$domain), na.rm = TRUE)))
+  range(trans$transform(range(squish(x, trans$domain), na.rm = TRUE)))
 }
diff --git a/README.md b/README.md
index 89f29e6..3d0344f 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
 
 [![Build Status](https://travis-ci.org/hadley/scales.png?branch=master)](https://travis-ci.org/hadley/scales)
 [![Coverage Status](https://img.shields.io/codecov/c/github/hadley/scales/master.svg)](https://codecov.io/github/hadley/scales?branch=master)
-[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/scales)](http://cran.r-project.org/web/packages/scales)
+[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/scales)](http://cran.r-project.org/package=scales)
 
 One of the most difficult parts of any graphics package is scaling, converting from data values to perceptual properties. The inverse of scaling, making guides (legends and axes) that can be used to read the graph, is often even harder! The idea of the `scales` package is to implement scales in a way that is graphics system agnostic, so that everyone can benefit by pooling knowledge and resources about this tricky topic.
 
diff --git a/build/partial.rdb b/build/partial.rdb
index 527592f..943b8e1 100644
Binary files a/build/partial.rdb and b/build/partial.rdb differ
diff --git a/man/alpha.Rd b/man/alpha.Rd
index e6cac66..a87b08b 100644
--- a/man/alpha.Rd
+++ b/man/alpha.Rd
@@ -20,6 +20,6 @@ Vectorised in both colour and alpha.
 \examples{
 alpha("red", 0.1)
 alpha(colours(), 0.5)
-alpha("red", seq(0, 1, length = 10))
+alpha("red", seq(0, 1, length.out = 10))
 }
 
diff --git a/man/brewer_pal.Rd b/man/brewer_pal.Rd
index 9b28c01..00db611 100644
--- a/man/brewer_pal.Rd
+++ b/man/brewer_pal.Rd
@@ -22,11 +22,11 @@ Color Brewer palette (discrete).
 \examples{
 show_col(brewer_pal()(10))
 show_col(brewer_pal("div")(5))
-show_col(brewer_pal(pal = "Greens")(5))
+show_col(brewer_pal(palette = "Greens")(5))
 
 # Can use with gradient_n to create a continous gradient
 cols <- brewer_pal("div")(5)
-show_col(gradient_n_pal(cols)(seq(0, 1, length = 30)))
+show_col(gradient_n_pal(cols)(seq(0, 1, length.out = 30)))
 }
 \references{
 \url{http://colorbrewer2.org}
diff --git a/man/date_trans.Rd b/man/date_trans.Rd
index 3f8b33f..88a9fea 100644
--- a/man/date_trans.Rd
+++ b/man/date_trans.Rd
@@ -12,8 +12,8 @@ Transformation for dates (class Date).
 \examples{
 years <- seq(as.Date("1910/1/1"), as.Date("1999/1/1"), "years")
 t <- date_trans()
-t$trans(years)
-t$inv(t$trans(years))
+t$transform(years)
+t$inverse(t$transform(years))
 t$format(t$breaks(range(years)))
 }
 
diff --git a/man/dichromat_pal.Rd b/man/dichromat_pal.Rd
index 0a33a85..3d9c055 100644
--- a/man/dichromat_pal.Rd
+++ b/man/dichromat_pal.Rd
@@ -19,6 +19,6 @@ show_col(dichromat_pal("BluetoOrange.10")(5))
 
 # Can use with gradient_n to create a continous gradient
 cols <- dichromat_pal("DarkRedtoBlue.12")(12)
-show_col(gradient_n_pal(cols)(seq(0, 1, length = 30)))
+show_col(gradient_n_pal(cols)(seq(0, 1, length.out = 30)))
 }
 
diff --git a/man/div_gradient_pal.Rd b/man/div_gradient_pal.Rd
index d925b3f..dcc203b 100644
--- a/man/div_gradient_pal.Rd
+++ b/man/div_gradient_pal.Rd
@@ -14,18 +14,18 @@ div_gradient_pal(low = mnsl("10B 4/6"), mid = mnsl("N 8/0"),
 
 \item{high}{colour for high end of gradient.}
 
-\item{space}{colour space in which to calculate gradient.  "Lab" usually
-best unless gradient goes through white.}
+\item{space}{colour space in which to calculate gradient. Must be "Lab" -
+other values are deprecated.}
 }
 \description{
 Diverging colour gradient (continous).
 }
 \examples{
-x <- seq(-1, 1, length = 100)
+x <- seq(-1, 1, length.out = 100)
 r <- sqrt(outer(x^2, x^2, "+"))
-image(r, col = div_gradient_pal()(seq(0, 1, length = 12)))
-image(r, col = div_gradient_pal()(seq(0, 1, length = 30)))
-image(r, col = div_gradient_pal()(seq(0, 1, length = 100)))
+image(r, col = div_gradient_pal()(seq(0, 1, length.out = 12)))
+image(r, col = div_gradient_pal()(seq(0, 1, length.out = 30)))
+image(r, col = div_gradient_pal()(seq(0, 1, length.out = 100)))
 
 library(munsell)
 image(r, col = div_gradient_pal(low =
diff --git a/man/gradient_n_pal.Rd b/man/gradient_n_pal.Rd
index f29b3ae..fbcac67 100644
--- a/man/gradient_n_pal.Rd
+++ b/man/gradient_n_pal.Rd
@@ -14,8 +14,8 @@ this vector gives the position (between 0 and 1) for each colour in the
 \code{colours} vector. See \code{\link{rescale}} for a convience function
 to map an arbitrary range to between 0 and 1.}
 
-\item{space}{colour space in which to calculate gradient.  "Lab" usually
-best unless gradient goes through white.}
+\item{space}{colour space in which to calculate gradient. Must be "Lab" -
+other values are deprecated.}
 }
 \description{
 Arbitrary colour gradient palette (continous).
diff --git a/man/rescale.Rd b/man/rescale.Rd
index 22861b1..b7e8985 100644
--- a/man/rescale.Rd
+++ b/man/rescale.Rd
@@ -4,7 +4,7 @@
 \alias{rescale}
 \title{Rescale numeric vector to have specified minimum and maximum.}
 \usage{
-rescale(x, to = c(0, 1), from = range(x, na.rm = TRUE))
+rescale(x, to = c(0, 1), from = range(x, na.rm = TRUE, finite = TRUE))
 }
 \arguments{
 \item{x}{numeric vector of values to manipulate.}
diff --git a/man/seq_gradient_pal.Rd b/man/seq_gradient_pal.Rd
index f105526..ad0b782 100644
--- a/man/seq_gradient_pal.Rd
+++ b/man/seq_gradient_pal.Rd
@@ -12,14 +12,14 @@ seq_gradient_pal(low = mnsl("10B 4/6"), high = mnsl("10R 4/6"),
 
 \item{high}{colour for high end of gradient.}
 
-\item{space}{colour space in which to calculate gradient.  "Lab" usually
-best unless gradient goes through white.}
+\item{space}{colour space in which to calculate gradient. Must be "Lab" -
+other values are deprecated.}
 }
 \description{
 Sequential colour gradient palette (continous).
 }
 \examples{
-x <- seq(0, 1, length = 25)
+x <- seq(0, 1, length.out = 25)
 show_col(seq_gradient_pal()(x))
 show_col(seq_gradient_pal("white", "black")(x))
 
diff --git a/man/time_trans.Rd b/man/time_trans.Rd
index 04ad475..08aeb2d 100644
--- a/man/time_trans.Rd
+++ b/man/time_trans.Rd
@@ -16,8 +16,8 @@ Transformation for times (class POSIXt).
 \examples{
 hours <- seq(ISOdate(2000,3,20, tz = ""), by = "hour", length.out = 10)
 t <- time_trans()
-t$trans(hours)
-t$inv(t$trans(hours))
+t$transform(hours)
+t$inverse(t$transform(hours))
 t$format(t$breaks(range(hours)))
 }
 
diff --git a/man/train_continuous.Rd b/man/train_continuous.Rd
new file mode 100644
index 0000000..88d0a83
--- /dev/null
+++ b/man/train_continuous.Rd
@@ -0,0 +1,17 @@
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/scale-continuous.r
+\name{train_continuous}
+\alias{train_continuous}
+\title{Train (update) a continuous scale}
+\usage{
+train_continuous(new, existing = NULL)
+}
+\arguments{
+\item{new}{New data to add to scale}
+
+\item{existing}{Optional existing scale to update}
+}
+\description{
+Train (update) a continuous scale
+}
+
diff --git a/man/train_discrete.Rd b/man/train_discrete.Rd
new file mode 100644
index 0000000..0455d61
--- /dev/null
+++ b/man/train_discrete.Rd
@@ -0,0 +1,19 @@
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/scale-discrete.r
+\name{train_discrete}
+\alias{train_discrete}
+\title{Train (update) a discrete scale}
+\usage{
+train_discrete(new, existing = NULL, drop = FALSE)
+}
+\arguments{
+\item{new}{New data to add to scale}
+
+\item{existing}{Optional existing scale to update}
+
+\item{drop}{\code{TRUE}, will drop factor levels not associated with data}
+}
+\description{
+Train (update) a discrete scale
+}
+
diff --git a/tests/testthat/test-alpha.r b/tests/testthat/test-alpha.r
index b5d0789..a436df8 100644
--- a/tests/testthat/test-alpha.r
+++ b/tests/testthat/test-alpha.r
@@ -7,7 +7,7 @@ hex <- function(x) {
 
 test_that("missing alpha preserves existing", {
   cols <- col2rgb(rep("red", 5), TRUE) / 255
-  cols[4, ] <- seq(0, 1, length = ncol(cols))
+  cols[4, ] <- seq(0, 1, length.out = ncol(cols))
 
   reds <- rgb(cols[1,], cols[2,], cols[3,], cols[4, ])
 
@@ -24,7 +24,7 @@ test_that("alpha values recycled to match colour", {
 })
 
 test_that("col values recycled to match alpha", {
-  alphas <- round(seq(0, 255, length = 3))
+  alphas <- round(seq(0, 255, length.out = 3))
   reds <- alpha("red", alphas / 255)
   reds_alpha <- col2rgb(reds, TRUE)[4, ]
   
diff --git a/tests/testthat/test-range.r b/tests/testthat/test-range.r
index e99c0c7..cf45507 100644
--- a/tests/testthat/test-range.r
+++ b/tests/testthat/test-range.r
@@ -1,30 +1,5 @@
 context("Ranges")
 
-test_that("continuous ranges expands as expected", {
-  r <- ContinuousRange$new()
-
-  r$train(1)  
-  expect_equal(r$range, c(1, 1))
-  
-  r$train(10)
-  expect_equal(r$range, c(1, 10))
-  
-})
-
-test_that("discrete ranges expands as expected", {
-  r <- DiscreteRange$new()
-
-  r$train("a")  
-  expect_equal(r$range, "a")
-  
-  r$train("b")
-  expect_equal(r$range, c("a", "b"))
-  
-  r$train(letters)
-  expect_equal(r$range, letters)  
-  
-})
-
 test_that("starting with NULL always returns new", {
   expect_equal(discrete_range(NULL, 1:3), 1:3)
   expect_equal(discrete_range(NULL, 3:1), 1:3)
diff --git a/tests/testthat/test-rescale.R b/tests/testthat/test-rescale.R
new file mode 100644
index 0000000..f8ff05e
--- /dev/null
+++ b/tests/testthat/test-rescale.R
@@ -0,0 +1,5 @@
+context("rescale")
+
+test_that("rescale preserves NAs even when x has zero range", {
+  expect_equal(rescale(c(1, NA)), c(0.5, NA))
+})
diff --git a/tests/testthat/test-scale.r b/tests/testthat/test-scale.r
index 3d4ccc2..73d8807 100644
--- a/tests/testthat/test-scale.r
+++ b/tests/testthat/test-scale.r
@@ -1,7 +1,7 @@
 context("Scale")
 
 test_that("NA.value works for continuous scales", {
-  x <- c(NA, seq(0, 1, length = 10), NA)
+  x <- c(NA, seq(0, 1, length.out = 10), NA)
   pal <- rescale_pal()
   
   expect_that(cscale(x, pal)[1], equals(NA_real_))

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/r-cran-scales.git



More information about the debian-med-commit mailing list