Learn R Programming

groupedHyperframe.random (version 0.2.2)

rfactor: Generate Random factor

Description

..

Usage

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

Value

Function rfactor() returns a factor.

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.

Examples

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

Run the code above in your browser using DataLab