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())
#> <BaseProvider> #> Public: #> bothify: function (text = "## ??") #> check_locale: function (x) #> clone: function (deep = FALSE) #> lexify: function (text = "????") #> numerify: function (text = "###") #> random_digit: function () #> random_digit_not_zero: function () #> random_digit_not_zero_or_empty: function () #> random_digit_or_empty: function () #> random_element: function (x) #> random_element_prob: function (x) #> random_int: function (min = 0, max = 9999, size = 1) #> random_letter: function () #> randomize_nb_elements: function (number = 10, le = FALSE, ge = FALSE, min = NULL, max = NULL)
x$numerify("#%%asdf221?")
#> [1] "511asdf221?"
x$lexify("#%%asdf221?")
#> [1] "#%%asdf221m"
x$bothify("#%%asdf221?")
#> [1] "793asdf221O"
z <- PhoneNumberProvider$new() x$numerify(z$render())
#> [1] "01812209643"
x$random_element(letters)
#> [1] "a"
x$random_int()
#> [1] 2736
x$random_digit()
#> [1] 5
x$random_digit_not_zero()
#> [1] 7
x$random_digit_or_empty()
#> [1] ""
x$random_digit_not_zero_or_empty()
#> [1] ""
x$random_letter()
#> [1] "N"
x$check_locale("es_ES") ## fails # x$check_locale("es_EQ") x$randomize_nb_elements()
#> [1] 7