R/slicesDeprecated.R

Defines functions slices

Documented in slices

#' Return vector of values from given interval
#'
#' Returns an ordered vector of values from given interval, of given size,
#' generated by equal steps.
#'
#' Returns a vector of values from \code{from} to \code{to} (inclusive), with
#' equal difference between two consecutive values, with total length \code{n}.
#' Function is useful e.g. together with the \code{\link{pbld}} or
#' \code{\link{defuzz}} functions (for the \code{values} argument; see also
#' \code{\link{lcut}} or \code{\link{fcut}}) or \code{\link{defuzz}}).
#'
#' @param from The lower bound of the interval.
#' @param to The upper bound of the interval.
#' @param n The length of the vector to be produced.
#' @return A vector of numbers in the given interval and size.
#' @author Michal Burda
#' @seealso \code{\link{pbld}}, \code{\link{defuzz}}, \code{\link{fcut}},
#' \code{\link{lcut}}
#' @keywords models robust
#' @examples
#' \dontrun{
#'     slices(1, 5, 10) # 1, 1.5, 2, 2.5, 3, 3.5 4, 4.5, 5
#' }
#' # is the same as
#' seq(1, 5, length.out=10)
#'
#'
#' @export slices
slices <- function(from, to, n) {
    .Deprecated('base::seq')
    if (!is.numeric(from) && length(from) != 1) {
        stop("'from' must be a numeric value")
    }
    if (!is.numeric(to) && length(to) != 1) {
        stop("'to' must be a numeric value")
    }
    if (!is.numeric(n) && length(n) != 1) {
        stop("'n' must be a numeric value")
    }
    if (n < 2) {
        stop("'n' must be at least 2")
    }
    res <- 0:(n-1) / (n-1) * (to - from) + from
    return(res)
}
beerda/lfl documentation built on Feb. 15, 2023, 8:15 a.m.