Generates a set of Logical values.

r_lgl(prob = 0.5, ..., n = default_n(prob), .seed = NULL)

Arguments

prob

vector of probability of TRUE results, between 0 & 1

...

Unused

n

number of observations to generate. The default_n() function will provide a default value within context

.seed

One of the following:

  • NULL (default) will not change the current seed. This is the usual case for generating random numbers.

  • A numeric value. This will be used to set the seed before generating the random numbers. This seed will be stored with the results.

  • TRUE. A random seed value will be generated and set as the seed before the results are generated. Again, this will be stored with the results.

To extract the random seed from a previously generated set of values, use pull_seed()

Value

A logical vector of length n

Examples

set_n(5) r_lgl(0.9)
#> [1] TRUE TRUE TRUE TRUE FALSE
r_lgl(seq(0, 1, 0.1))
#> [1] FALSE FALSE FALSE FALSE TRUE TRUE FALSE TRUE TRUE TRUE TRUE
r_lgl(1 / 4, n = 10)
#> [1] FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE TRUE FALSE