diff --git a/R/colour-manip.r b/R/colour-manip.r index 241f2d29..b96d3d59 100644 --- a/R/colour-manip.r +++ b/R/colour-manip.r @@ -50,7 +50,7 @@ muted <- function(colour, l=30, c=70) col2hcl(colour, l=l, c=c) #' @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 diff --git a/R/pal-brewer.r b/R/pal-brewer.r index 325a339e..7b28b2f4 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 706aac9b..b7c55248 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 da60ab48..ce04f217 100644 --- a/R/pal-gradient.r +++ b/R/pal-gradient.r @@ -1,25 +1,25 @@ #' 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. +#' best unless gradient goes through white. #' @export gradient_n_pal <- function(colours, values = NULL, space = "Lab") { ramp <- colorRamp(colours, space = space) function(x) { if (length(x) == 0) return(character()) - + if (!is.null(values)) { - xs <- seq(0, 1, length = length(values)) + xs <- seq(0, 1, length.out = length.out(values)) f <- approxfun(values, xs) x <- f(x) } - + nice_rgb(ramp(x)) } } @@ -34,36 +34,36 @@ nice_rgb <- function(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. +#' best unless gradient goes through white. #' @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 = -#' mnsl(complement("10R 4/6", fix = TRUE)))(seq(0, 1, length = 100))) +#' image(r, col = div_gradient_pal(low = +#' mnsl(complement("10R 4/6", fix = TRUE)))(seq(0, 1, length.out = 100))) 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. +#' best unless gradient goes through white. #' @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-hue.r b/R/pal-hue.r index 8afd14ab..3c72d664 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 70d39cee..0bb331d2 100644 --- a/R/scale-continuous.r +++ b/R/scale-continuous.r @@ -23,7 +23,7 @@ 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) } diff --git a/R/trans-date.r b/R/trans-date.r index 9dd0fe63..1fd9c354 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 0cad808e..8d6354d1 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/man/alpha.Rd b/man/alpha.Rd index e6cac660..a87b08b3 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 9b28c019..00db611f 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 3f8b33f7..88a9feac 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 0a33a858..3d9c0551 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 d925b3f2..ed8d0d2a 100644 --- a/man/div_gradient_pal.Rd +++ b/man/div_gradient_pal.Rd @@ -21,14 +21,14 @@ best unless gradient goes through white.} 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 = - mnsl(complement("10R 4/6", fix = TRUE)))(seq(0, 1, length = 100))) + mnsl(complement("10R 4/6", fix = TRUE)))(seq(0, 1, length.out = 100))) } diff --git a/man/seq_gradient_pal.Rd b/man/seq_gradient_pal.Rd index f105526e..e8621abe 100644 --- a/man/seq_gradient_pal.Rd +++ b/man/seq_gradient_pal.Rd @@ -19,7 +19,7 @@ best unless gradient goes through white.} 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 04ad475a..08aeb2db 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/tests/testthat/test-alpha.r b/tests/testthat/test-alpha.r index b5d07896..a436df80 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-scale.r b/tests/testthat/test-scale.r index 3d4ccc23..73d8807b 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_))