genPattern {conjurer}R Documentation

Generate a pattern

Description

Generates data based on a pattern. This function is used by another internal function buildPattern.

Usage

genPattern(orderedList)

Arguments

orderedList

A list of lists. The element valuesvalues of the sublist is a vector of characters(string or numeric or special character) and the element probsprobs is a vector of probabilities. The range of the probs is 0 to 1 and length of the probsprobs vector is either equal to length of valuesvalues or NULL.

Details

This function helps in generating data based on a pattern. To explain in simple terms, this function aims to perform the exact opposite of a regular expression i.e regex function. In other words, this function generates data given a generic pattern. The input is a list of components that make up the pattern. Each component i.e element of the list is a also list with two vectors namely valuesvalues and probsprobs. The vector valuesvalues has the set of values out of which one of them is selected randomly. If this random selection is supposed to be completely random, then the next vector probsprobs can be left empty i.e. NULL. However, if the random selection of values is expected to follow a a pre-determined probabilistic distribution, then the probabilities must be provided explicitly. To explain further, if there are three values aa, bb, cc and their probabilistic distribution must be 25 percent, 50 percent and 25 percent respectively, then the vector valuesvalues will take the form c(a,b,c)c(a,b,c) and the vector probsprobs will take the form c(0.25,0.5,0.25)c(0.25,0.5,0.25).

Value

A character vector.

See Also

[buildPattern()]


[Package conjurer version 1.7.1 Index]