R/sample1.R

Defines functions sample1

Documented in sample1

#' sample1
#'
#' Returns one (default) or several numbers from a range of numbers generated by the seq() function.
#' @param from Starting value of the range ob possible values.
#' @param to Ending value of the range of possible values.
#' @param by Step size for the range of possible values.
#' @param size Number of random values to draw.
#' @keywords sample
#' @export
#' @examples
#' # Return one integer out of the set {1, 2,..., 100}
#' sample1()
#' # Return two integers out of the set {0, 2.5, 5, 7.5, 10}
#' sample1(from = 0, to = 10, by = 2.5, size = 2)
#'
sample1 <- function(from = 1, to = 100, by = 1, size = 1) {
  require(base, quietly = TRUE)
  sample(seq(from = from, to = to, by = by), size = size)
}
stpalan/SPTools documentation built on Aug. 21, 2023, 11:21 a.m.