rfactor: Generate Random factor

View source: R/rfactor.R

rfactorR Documentation

Generate Random factor

Description

..

Usage

rfactor(n, prob, levels = as.character(seq_len(nprob)))

Arguments

n

integer scalar

prob

numeric vector, see function sample.int

levels

character vector, see function factor

Details

Function rfactor() is a wrapper of sample.int.

Value

Function rfactor() returns a factor.

Note

Function rmultinom is not what we need!

Examples

rfactor(n = 100L, prob = c(4,2,3))
rfactor(n = 100L, prob = c(4,2,3), levels = letters[1:3])

groupedHyperframe.random documentation built on Jan. 25, 2026, 1:06 a.m.