Learn R Programming

random.cdisc.data (version 0.3.16)

sample_fct: Create a Factor with Random Elements of x

Description

Sample elements from x with replacement to build a factor.

Usage

sample_fct(x, N, ...)

Value

A factor of length N.

Arguments

x

(character vector or factor)
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

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

Run the code above in your browser using DataLab