Sample elements from x with replacing and build a factor

sample_fct(x, 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

...

arguments passed on to sample

Value

a factor of length N

Examples

random.cdisc.data:::sample_fct(letters[1:3], 10)
#>  [1] c a c b b b b a c b
#> Levels: a b c
random.cdisc.data:::sample_fct(iris$Species, 10)
#>  [1] versicolor setosa     virginica  versicolor versicolor versicolor
#>  [7] versicolor versicolor virginica  versicolor
#> Levels: setosa versicolor virginica