Skip to contents

stm_random_vector() generates a random vector with values between the specified minimum and maximum. Optionally, the vector can be sorted in increasing or decreasing order.

Usage

stm_random_vector(
  min = 10,
  max = 99,
  n = 10,
  replace = TRUE,
  set_seed = NULL,
  is_sorted = FALSE,
  is_decreasing = FALSE
)

Arguments

min

The minimum value of the vector elements. Default is 10.

max

The maximum value of the vector elements. Default is 99.

n

The number of elements in the vector. Default is 10.

replace

A logical indicating whether sampling is with replacement. Default is TRUE.

set_seed

Optional seed for random number generation.

is_sorted

A logical indicating whether to sort the vector. Default is FALSE.

is_decreasing

A logical indicating whether to sort the vector in decreasing order. Default is FALSE.

Value

A numeric vector of random values, optionally sorted.

Details

This function generates a random vector with the specified number of elements and value range. The vector can be sorted in increasing or decreasing order based on the is_sorted and is_decreasing parameters.

Examples

stm_random_vector()
#>  [1] 74 34 83 27 58 56 33 80 98 46
stm_random_vector(n = 5, is_sorted = TRUE)
#> [1] 12 29 35 50 98
stm_random_vector(
  n = 8, is_sorted = TRUE, is_decreasing = TRUE, set_seed = 42
)
#> [1] 83 74 58 58 56 34 33 27