BaseProvider {charlatan} | R Documentation |
BaseProvider
Description
BaseProvider
BaseProvider
Methods
Public methods
Method random_element()
pick a random element from vector/list
Usage
BaseProvider$random_element(x)
Arguments
x
vector or list
Returns
a single element from x
Method random_element_prob()
pick a random element with probability from vector/list
Usage
BaseProvider$random_element_prob(x)
Arguments
x
vector or list
Method random_int()
any number of random integers from a min, max
Usage
BaseProvider$random_int(min = 0, max = 9999, size = 1)
Arguments
min
the minimum value. default: 0
max
the maximum value. default: 9999
size
number of values to return. default: 1
Returns
random integer
Method random_digit()
random integer between 0 and 9
Usage
BaseProvider$random_digit()
Method random_digit_not_zero()
random integer between 1 and 9
Usage
BaseProvider$random_digit_not_zero()
Method random_digit_or_empty()
random integer between 0 and 9 or empty character string
Usage
BaseProvider$random_digit_or_empty()
Method random_digit_not_zero_or_empty()
random integer between 1 and 9 or empty character string
Usage
BaseProvider$random_digit_not_zero_or_empty()
Method random_letter()
random letter
Usage
BaseProvider$random_letter()
Method numerify()
replace a template with numbers
Usage
BaseProvider$numerify(text = "###")
Arguments
text
(character) a string
Method lexify()
replace a template with letters
Usage
BaseProvider$lexify(text = "????")
Arguments
text
(character) a string
Method bothify()
both numerify and lexify together
Usage
BaseProvider$bothify(text = "## ??")
Arguments
text
(character) a string
Method check_locale()
check a locale to see if it exists, if not, stop with error message
Usage
BaseProvider$check_locale(x)
Arguments
x
a locale name, e.g, 'bg_BG'
Returns
returns nothing if locale is supported; stops w/ message if not
Method randomize_nb_elements()
Returns a random value near number
Usage
BaseProvider$randomize_nb_elements( number = 10, le = FALSE, ge = FALSE, min = NULL, max = NULL )
Arguments
number
value to which the result must be near
le
result must be lower or equal to number
ge
result must be greater or equal to number
min
the minimum value. default:
NULL
max
the maximum value. default:
NULL
Returns
a random int near number
Method clone()
The objects of this class are cloneable with this method.
Usage
BaseProvider$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
(x <- BaseProvider$new())
x$numerify("#%%asdf221?")
x$lexify("#%%asdf221?")
x$bothify("#%%asdf221?")
z <- PhoneNumberProvider$new()
x$numerify(z$render())
x$random_element(letters)
x$random_int()
x$random_digit()
x$random_digit_not_zero()
x$random_digit_or_empty()
x$random_digit_not_zero_or_empty()
x$random_letter()
x$check_locale("es_ES")
## fails
# x$check_locale("es_EQ")
x$randomize_nb_elements()