samps: Create a factor with random elements of x

sample_fctR Documentation

Create a factor with random elements of x

Description

Sample elements from x with replacing and build a factor

Usage

sample_fct(x, n, ...)

sample_yn(n)

rep_n(val, n, ...)

seq_n(n, ...)

Arguments

x

character vector or factor, if character vector then it is also used as levels of the returned factor, otherwise if it is a factor then the levels get used as the new levels

n

number of observations to sample.

...

arguments passed on to sample

val

ANY. Single value to be repeated n times

Value

a factor of length N

Examples

sample_fct(letters[1:3], 10)
sample_fct(iris$Species, 10)

sample_yn(3)

rep_n("aaa", 5)
rep_n(1:5, 2)

seq_n(10)


Roche/respectables documentation built on Oct. 2, 2024, 8:57 p.m.