diff --git a/NEWS.md b/NEWS.md index 6ac3a85..d6f6a6d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# development version + + * The argument `to.range` of `normalise()` has been renamed to `to_range`. + # eaf 2.5 * Silence some warnings with GCC 12. diff --git a/R/normalise.R b/R/normalise.R index 0295ed9..ab9ee5b 100644 --- a/R/normalise.R +++ b/R/normalise.R @@ -6,8 +6,8 @@ #' #' @template arg_data #' -#' @param to.range Normalise values to this range. If the objective is -#' maximised, it is normalised to \code{c(to.range[1], to.range[0])} +#' @param to_range Normalise values to this range. If the objective is +#' maximised, it is normalised to \code{c(to_range[1], to_range[0])} #' instead. #' #' @param lower,upper Bounds on the values. If NA, the maximum and minimum @@ -27,10 +27,10 @@ #' #' head(normalise(SPEA2minstoptimeRichmond[, 1:2], maximise = c(FALSE, TRUE))) #' -#' head(normalise(SPEA2minstoptimeRichmond[, 1:2], to.range = c(0,1), maximise = c(FALSE, TRUE))) +#' head(normalise(SPEA2minstoptimeRichmond[, 1:2], to_range = c(0,1), maximise = c(FALSE, TRUE))) #' #' @export -normalise <- function(data, to.range = c(1, 2), lower = NA, upper = NA, maximise = FALSE) +normalise <- function(data, to_range = c(1, 2), lower = NA, upper = NA, maximise = FALSE) { data <- check_dataset(data) nobjs <- ncol(data) @@ -45,14 +45,14 @@ normalise <- function(data, to.range = c(1, 2), lower = NA, upper = NA, maximise upper[no.upper] <- minmax[no.upper, 2L] maximise <- as.logical(rep_len(maximise, nobjs)) - if (length(to.range) != 2L) - stop("to.range must be a vector of length 2") + if (length(to_range) != 2L) + stop("to_range must be a vector of length 2") z <- t(.Call(normalise_C, as.double(t(data)), as.integer(nobjs), as.integer(npoints), - as.double(to.range), + as.double(to_range), lower, upper, maximise)) colnames(z) <- colnames(data) rownames(z) <- rownames(data) diff --git a/man/normalise.Rd b/man/normalise.Rd index 3f44134..a958370 100644 --- a/man/normalise.Rd +++ b/man/normalise.Rd @@ -4,14 +4,14 @@ \alias{normalise} \title{Normalise points} \usage{ -normalise(data, to.range = c(1, 2), lower = NA, upper = NA, maximise = FALSE) +normalise(data, to_range = c(1, 2), lower = NA, upper = NA, maximise = FALSE) } \arguments{ \item{data}{(\code{matrix} | \code{data.frame}) \cr Matrix or data frame of numerical values, where each row gives the coordinates of a point.} -\item{to.range}{Normalise values to this range. If the objective is -maximised, it is normalised to \code{c(to.range[1], to.range[0])} +\item{to_range}{Normalise values to this range. If the objective is +maximised, it is normalised to \code{c(to_range[1], to_range[0])} instead.} \item{lower, upper}{Bounds on the values. If NA, the maximum and minimum @@ -38,7 +38,7 @@ head(SPEA2minstoptimeRichmond[, 1:2]) head(normalise(SPEA2minstoptimeRichmond[, 1:2], maximise = c(FALSE, TRUE))) -head(normalise(SPEA2minstoptimeRichmond[, 1:2], to.range = c(0,1), maximise = c(FALSE, TRUE))) +head(normalise(SPEA2minstoptimeRichmond[, 1:2], to_range = c(0,1), maximise = c(FALSE, TRUE))) } \author{ diff --git a/tests/testthat/test-normalise.R b/tests/testthat/test-normalise.R index fa72f30..11e0e21 100644 --- a/tests/testthat/test-normalise.R +++ b/tests/testthat/test-normalise.R @@ -10,7 +10,7 @@ test_that("normalise", { expect_equal(normalise(x, maximise = c(FALSE,TRUE)), my.2d.matrix(1, 1.5, 2, 2, 1.5, 1)) - expect_equal(normalise(x, to.range = c(0, 1), maximise = c(FALSE,TRUE)), + expect_equal(normalise(x, to_range = c(0, 1), maximise = c(FALSE,TRUE)), my.2d.matrix(0, 0.5, 1, 1, 0.5, 0)) expect_equal(normalise(my.2d.matrix(1,1,2,2)), my.2d.matrix(1,1,1,1))