Create a Factor with Random Elements of x
sample_fct.Rd
Sample elements from x
with replacement to build a factor.
Arguments
- x
(
character vector
orfactor
)
If character vector then it is also used as levels of the returned factor. If factor then the levels are used as the new levels.- N
(
numeric
)
Number of items to choose.- ...
Additional arguments to be passed to
sample
.
Examples
random.cdisc.data:::sample_fct(letters[1:3], 10)
#> [1] b b b c a a b b b b
#> Levels: a b c
random.cdisc.data:::sample_fct(iris$Species, 10)
#> [1] versicolor versicolor virginica virginica virginica versicolor
#> [7] versicolor setosa virginica versicolor
#> Levels: setosa versicolor virginica