rcode: Generate random code field

Description Usage Arguments Details Examples

View source: R/random_generators.R

Description

Build random code fields using rchar as the underlying workhorse.

Usage

1
rcode(nlevels = 10, cols, size, codevec = NULL, along = NULL, ...)

Arguments

nlevels

Number of levels for the code keys

cols

Column name for the generated data

size

Number of rows to be generated

codevec

Explicit vector of codes to use

along

A vector (or one-column data.frame) to match the code keys with.

Details

For extra parameters such as code field length and type, see rchar.

Examples

1
2
3
4
5
6
7
# Basic use
rcode(2, "codes", 10)
rcode(NA, "codes", 10, codevec=c("foo", "bar","xyzzy"))

# Using the along feature
docname <- sample(c("Jofn A Doc", "Jane D Doc"), 10, replace=TRUE)
rcode(along=docname, cols="doccode", type="A0", slength=3)

avirkki/synergetr documentation built on May 18, 2019, 9:16 p.m.