Skip to contents

address methods

Super class

charlatan::BaseProvider -> AddressProvider

Public fields

locale

(character) xxx

city_prefixes

(character) xxx

city_suffixes

(character) xxx

street_suffixes

(character) xxx

building_number_formats

(character) xxx

postcode_formats

(character) xxx

states

(character) xxx

states_abbr

(character) xxx

military_state_abbr

(character) xxx

military_ship_prefix

(character) xxx

military_apo_format

(character) xxx

military_dpo_format

(character) xxx

city_formats

(character) xxx

street_name_formats

(character) xxx

street_address_formats

(character) xxx

address_formats

(character) xxx

secondary_address_formats

(character) xxx

countries

(character) xxx

country_codes

(character) xxx

locale_data

(character) xxx

Methods

Inherited methods


Method allowed_locales()

fetch the allowed locales for this provider

Usage

AddressProvider$allowed_locales()


Method new()

Create a new AddressProvider object

Usage

AddressProvider$new(locale = NULL)

Arguments

locale

(character) the locale to use. See $allowed_locales() for locales supported (default: en_US)

Returns

A new AddressProvider object


Method city_suffix()

city suffix

Usage

AddressProvider$city_suffix()


Method street_suffix()

street suffix

Usage

AddressProvider$street_suffix()


Method building_number()

building numeber

Usage

AddressProvider$building_number()


Method city()

city

Usage

AddressProvider$city()


Method street_name()

street name

Usage

AddressProvider$street_name()


Method street_address()

street address

Usage

AddressProvider$street_address()


Method postcode()

postal code

Usage

AddressProvider$postcode()


Method address()

address

Usage

AddressProvider$address()


Method country()

country name

Usage

AddressProvider$country()


Method country_code()

country code

Usage

AddressProvider$country_code()


Method clone()

The objects of this class are cloneable with this method.

Usage

AddressProvider$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

(z <- AddressProvider$new())
#> <AddressProvider>
#>   Inherits from: <BaseProvider>
#>   Public:
#>     address: function () 
#>     address_formats: {{street_address}}
#>     {{city}}, {{state_abbr}} {{postcode}}
#>     allowed_locales: function () 
#>     bothify: function (text = "## ??") 
#>     building_number: function () 
#>     building_number_formats: ##### #### ###
#>     check_locale: function (x) 
#>     city: function () 
#>     city_formats: {{city_prefix}} {{first_name}}{{city_suffix}} {{city_pre ...
#>     city_prefixes: North East West South New Lake Port
#>     city_suffix: function () 
#>     city_suffixes: town ton land ville berg burgh borough bury view port mo ...
#>     clone: function (deep = FALSE) 
#>     countries: Andorra Afghanistan Antigua and Barbuda Albania Armenia  ...
#>     country: function () 
#>     country_code: function () 
#>     country_codes: AD AF AG AL AM AO AR AT AU AZ BB BD BE BF BG BH BI BJ BN ...
#>     initialize: function (locale = NULL) 
#>     lexify: function (text = "????") 
#>     locale: en_US
#>     locale_data: NULL
#>     military_apo_format: PSC ####, Box ####
#>     military_dpo_format: Unit #### Box ####
#>     military_ship_prefix: USS USNS USNV USCGC
#>     military_state_abbr: AE AA AP
#>     numerify: function (text = "###") 
#>     postcode: function () 
#>     postcode_formats: ##### #####-####
#>     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) 
#>     secondary_address_formats: Apt. ### Suite ###
#>     states: Alabama Alaska Arizona Arkansas California Colorado Conn ...
#>     states_abbr: AL AK AS AZ AR CA CO CT DE DC FM FL GA GU HI ID IL IN IA ...
#>     street_address: function () 
#>     street_address_formats: {{building_number}} {{street_name}} {{building_number}}  ...
#>     street_name: function () 
#>     street_name_formats: {{first_name}} {{street_suffix}} {{last_name}} {{street_ ...
#>     street_suffix: function () 
#>     street_suffixes: Alley Avenue Branch Bridge Brook Brooks Burg Burgs Bypas ...
#>   Private:
#>     locales: en_US en_GB en_NZ es_ES nl_NL
z$locale
#> [1] "en_US"
z$allowed_locales()
#> [1] "en_US" "en_GB" "en_NZ" "es_ES" "nl_NL"
z$city_suffix()
#> [1] "land"
z$street_suffix()
#> [1] "Pines"
z$building_number()
#> [1] "76409"
z$city()
#> [1] "West Zaria"
z$country()
#> [1] "Zambia"
z$street_name()
#> [1] "Goldner View"
z$street_address()
#> [1] "6357 Hansen Valley"
z$address()
#> [1] "3179 Yancy Gateway Apt. 107\nNorth Anastasiaport, NM 66787-4751"
z$country()
#> [1] "Bahrain"
z$country_code()
#> [1] "BA"
z$postcode()
#> [1] "61603"

# en_GB
(z <- AddressProvider$new('en_GB'))
#> <AddressProvider>
#>   Inherits from: <BaseProvider>
#>   Public:
#>     address: function () 
#>     address_formats: {{street_address}}
#>     {{city}}
#>     {{postcode}}
#>     allowed_locales: function () 
#>     bothify: function (text = "## ??") 
#>     building_number: function () 
#>     building_number_formats: # ## ###
#>     check_locale: function (x) 
#>     city: function () 
#>     city_formats: {{city_prefix}} {{first_name}}{{city_suffix}} {{city_pre ...
#>     city_prefixes: North East West South New Lake Port
#>     city_suffix: function () 
#>     city_suffixes: town ton land ville berg burgh borough bury view port mo ...
#>     clone: function (deep = FALSE) 
#>     countries: Andorra Afghanistan Antigua and Barbuda Albania Armenia  ...
#>     country: function () 
#>     country_code: function () 
#>     country_codes: AD AF AG AL AM AO AR AT AU AZ BB BD BE BF BG BH BI BJ BN ...
#>     initialize: function (locale = NULL) 
#>     lexify: function (text = "????") 
#>     locale: en_GB
#>     locale_data: list
#>     military_apo_format: NULL
#>     military_dpo_format: NULL
#>     military_ship_prefix: NULL
#>     military_state_abbr: NULL
#>     numerify: function (text = "###") 
#>     postcode: function () 
#>     postcode_formats: AN NEE ANN NEE PN NEE PNN NEE ANC NEE PND NEE
#>     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) 
#>     secondary_address_formats: Flat # Flat ## Flat ##? Studio # Studio ## Studio ##?
#>     states: NULL
#>     states_abbr: NULL
#>     street_address: function () 
#>     street_address_formats: {{building_number}} {{street_name}} {{secondary_address} ...
#>     street_name: function () 
#>     street_name_formats: {{first_name}} {{street_suffix}} {{last_name}} {{street_ ...
#>     street_suffix: function () 
#>     street_suffixes: alley avenue branch bridge brook brooks burg burgs bypas ...
#>   Private:
#>     locales: en_US en_GB en_NZ es_ES nl_NL
z$locale
#> [1] "en_GB"
z$locale_data
#> $postcode_sets
#> $postcode_sets$` `
#> [1] " "
#> 
#> $postcode_sets$N
#>  [1] 0 1 2 3 4 5 6 7 8 9
#> 
#> $postcode_sets$A
#> [1] "B" "E" "G" "L" "M" "N" "S" "W"
#> 
#> $postcode_sets$B
#>  [1] "A" "B" "C" "D" "E" "F" "G" "H" "K" "L" "M" "N" "O" "P" "Q" "R" "S" "T" "U"
#> [20] "V" "W" "X" "Y"
#> 
#> $postcode_sets$C
#>  [1] "A" "B" "C" "D" "E" "F" "G" "H" "J" "K" "S" "T" "U" "W"
#> 
#> $postcode_sets$D
#>  [1] "A" "B" "E" "H" "M" "N" "P" "R" "V" "W" "X" "Y"
#> 
#> $postcode_sets$E
#>  [1] "A" "B" "D" "E" "F" "G" "H" "J" "L" "N" "P" "Q" "R" "S" "T" "U" "W" "X" "Y"
#> [20] "Z"
#> 
#> $postcode_sets$P
#>   [1] "AB" "AL" "BA" "BB" "BD" "BH" "BL" "BN" "BR" "BS" "BT" "CA" "CB" "CF" "CH"
#>  [16] "CM" "CO" "CR" "CT" "CV" "CW" "DA" "DD" "DE" "DG" "DH" "DL" "DN" "DT" "DY"
#>  [31] "EC" "EH" "EN" "EX" "FK" "FY" "GL" "GY" "GU" "HA" "HD" "HG" "HP" "HR" "HS"
#>  [46] "HU" "HX" "IG" "IM" "IP" "IV" "JE" "KA" "KT" "KW" "KY" "LA" "LD" "LE" "LL"
#>  [61] "LN" "LS" "LU" "ME" "MK" "ML" "NE" "NG" "NN" "NP" "NR" "NW" "OL" "OX" "PA"
#>  [76] "PE" "PH" "PL" "PO" "PR" "RG" "RH" "RM" "SA" "SE" "SG" "SK" "SL" "SM" "SN"
#>  [91] "SO" "SP" "SR" "SS" "ST" "SW" "SY" "TA" "TD" "TF" "TN" "TQ" "TR" "TS" "TW"
#> [106] "UB" "WA" "WC" "WD" "WF" "WN" "WR" "WS" "WV" "YO" "ZE"
#> 
#> 
z$locale_data$postcode_sets
#> $` `
#> [1] " "
#> 
#> $N
#>  [1] 0 1 2 3 4 5 6 7 8 9
#> 
#> $A
#> [1] "B" "E" "G" "L" "M" "N" "S" "W"
#> 
#> $B
#>  [1] "A" "B" "C" "D" "E" "F" "G" "H" "K" "L" "M" "N" "O" "P" "Q" "R" "S" "T" "U"
#> [20] "V" "W" "X" "Y"
#> 
#> $C
#>  [1] "A" "B" "C" "D" "E" "F" "G" "H" "J" "K" "S" "T" "U" "W"
#> 
#> $D
#>  [1] "A" "B" "E" "H" "M" "N" "P" "R" "V" "W" "X" "Y"
#> 
#> $E
#>  [1] "A" "B" "D" "E" "F" "G" "H" "J" "L" "N" "P" "Q" "R" "S" "T" "U" "W" "X" "Y"
#> [20] "Z"
#> 
#> $P
#>   [1] "AB" "AL" "BA" "BB" "BD" "BH" "BL" "BN" "BR" "BS" "BT" "CA" "CB" "CF" "CH"
#>  [16] "CM" "CO" "CR" "CT" "CV" "CW" "DA" "DD" "DE" "DG" "DH" "DL" "DN" "DT" "DY"
#>  [31] "EC" "EH" "EN" "EX" "FK" "FY" "GL" "GY" "GU" "HA" "HD" "HG" "HP" "HR" "HS"
#>  [46] "HU" "HX" "IG" "IM" "IP" "IV" "JE" "KA" "KT" "KW" "KY" "LA" "LD" "LE" "LL"
#>  [61] "LN" "LS" "LU" "ME" "MK" "ML" "NE" "NG" "NN" "NP" "NR" "NW" "OL" "OX" "PA"
#>  [76] "PE" "PH" "PL" "PO" "PR" "RG" "RH" "RM" "SA" "SE" "SG" "SK" "SL" "SM" "SN"
#>  [91] "SO" "SP" "SR" "SS" "ST" "SW" "SY" "TA" "TD" "TF" "TN" "TQ" "TR" "TS" "TW"
#> [106] "UB" "WA" "WC" "WD" "WF" "WN" "WR" "WS" "WV" "YO" "ZE"
#> 
z$postcode
#> function () 
#> {
#>     switch(self$locale, en_US = toupper(super$bothify(super$random_element(self$postcode_formats))), 
#>         en_GB = {
#>             pcode <- ""
#>             pattern <- super$random_element(self$postcode_formats)
#>             pattern <- strsplit(pattern, split = "")[[1]]
#>             for (p in pattern) {
#>                 pcode <- paste0(pcode, super$random_element(self$locale_data$postcode_sets[[p]]))
#>             }
#>             pcode
#>         }, nl_NL = {
#>             paste0(super$random_element(1000:9999), " ", super$random_element(LETTERS), 
#>                 super$random_element(LETTERS))
#>         })
#> }
#> <environment: 0x55a861f59778>
z$postcode()
#> [1] "DL80 5EH"
z$street_name()
#> [1] "Pearce isle"

# en_NZ
(z <- AddressProvider$new('en_NZ'))
#> <AddressProvider>
#>   Inherits from: <BaseProvider>
#>   Public:
#>     address: function () 
#>     address_formats: {{street_address}}
#>     {{city}} {{postcode}}
#>     allowed_locales: function () 
#>     bothify: function (text = "## ??") 
#>     building_number: function () 
#>     building_number_formats: %## %# %
#>     check_locale: function (x) 
#>     city: function () 
#>     city_formats: {{first_name}}{{city_suffix}} {{last_name}}{{city_suffix ...
#>     city_prefixes: North East West South New Lake Port Upper Lower High Mount
#>     city_suffix: function () 
#>     city_suffixes: town ton land ville berg burgh borough bury burn ing por ...
#>     clone: function (deep = FALSE) 
#>     countries: Andorra Afghanistan Antigua and Barbuda Albania Armenia  ...
#>     country: function () 
#>     country_code: function () 
#>     country_codes: AD AF AG AL AM AO AR AT AU AZ BB BD BE BF BG BH BI BJ BN ...
#>     initialize: function (locale = NULL) 
#>     lexify: function (text = "????") 
#>     locale: en_NZ
#>     locale_data: list
#>     military_apo_format: NULL
#>     military_dpo_format: NULL
#>     military_ship_prefix: NULL
#>     military_state_abbr: NULL
#>     numerify: function (text = "###") 
#>     postcode: function () 
#>     postcode_formats: 0%## 1### 20## 21## 22## 23## 24## 25## 26## 3### 4### 5 ...
#>     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) 
#>     secondary_address_formats: Apt. %## Flat %# Suite %## Unit %# Level %
#>     states: NULL
#>     states_abbr: NULL
#>     street_address: function () 
#>     street_address_formats: {{building_number}} {{street_name}} {{building_number}}  ...
#>     street_name: function () 
#>     street_name_formats: {{first_name}} {{street_suffix}} {{last_name}} {{street_ ...
#>     street_suffix: function () 
#>     street_suffixes: Arcade Arcade Arcade Avenue Avenue Avenue Avenue Avenue  ...
#>   Private:
#>     locales: en_US en_GB en_NZ es_ES nl_NL
z$locale
#> [1] "en_NZ"
z$street_name()
#> [1] "Taitangi Road"

# es_ES
(z <- AddressProvider$new('es_ES'))
#> <AddressProvider>
#>   Inherits from: <BaseProvider>
#>   Public:
#>     address: function () 
#>     address_formats: NULL
#>     allowed_locales: function () 
#>     bothify: function (text = "## ??") 
#>     building_number: function () 
#>     building_number_formats: NULL
#>     check_locale: function (x) 
#>     city: function () 
#>     city_formats: NULL
#>     city_prefixes: NULL
#>     city_suffix: function () 
#>     city_suffixes: NULL
#>     clone: function (deep = FALSE) 
#>     countries: Andorra Afghanistan Antigua and Barbuda Albania Armenia  ...
#>     country: function () 
#>     country_code: function () 
#>     country_codes: AD AF AG AL AM AO AR AT AU AZ BB BD BE BF BG BH BI BJ BN ...
#>     initialize: function (locale = NULL) 
#>     lexify: function (text = "????") 
#>     locale: es_ES
#>     locale_data: NULL
#>     military_apo_format: NULL
#>     military_dpo_format: NULL
#>     military_ship_prefix: NULL
#>     military_state_abbr: NULL
#>     numerify: function (text = "###") 
#>     postcode: function () 
#>     postcode_formats: NULL
#>     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) 
#>     secondary_address_formats: NULL
#>     states: NULL
#>     states_abbr: NULL
#>     street_address: function () 
#>     street_address_formats: NULL
#>     street_name: function () 
#>     street_name_formats: NULL
#>     street_suffix: function () 
#>     street_suffixes: NULL
#>   Private:
#>     locales: en_US en_GB en_NZ es_ES nl_NL
z$locale
#> [1] "es_ES"
z$street_name()
#> [1] ""

# nl_NL
(z <- AddressProvider$new('nl_NL'))
#> <AddressProvider>
#>   Inherits from: <BaseProvider>
#>   Public:
#>     address: function () 
#>     address_formats: {{street_address}}
#>     {{postcode}} {{city}}
#>     allowed_locales: function () 
#>     bothify: function (text = "## ??") 
#>     building_number: function () 
#>     building_number_formats: # ## ###
#>     check_locale: function (x) 
#>     city: function () 
#>     city_formats: {{city_prefix}}{{city_suffix}} {{first_name}}{{city_suffix}}
#>     city_prefixes: Veen U Amster Heeren Ooster Nieuw Amers Maas Kaas Pieter ...
#>     city_suffix: function () 
#>     city_suffixes: daal dael endaal  trecht tricht land stad berg burg dam  ...
#>     clone: function (deep = FALSE) 
#>     countries: Andorra Afghanistan Antigua and Barbuda Albania Armenia  ...
#>     country: function () 
#>     country_code: function () 
#>     country_codes: AD AF AG AL AM AO AR AT AU AZ BB BD BE BF BG BH BI BJ BN ...
#>     initialize: function (locale = NULL) 
#>     lexify: function (text = "????") 
#>     locale: nl_NL
#>     locale_data: NULL
#>     military_apo_format: NULL
#>     military_dpo_format: NULL
#>     military_ship_prefix: NULL
#>     military_state_abbr: NULL
#>     numerify: function (text = "###") 
#>     postcode: function () 
#>     postcode_formats: ####
#>     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) 
#>     secondary_address_formats: NULL
#>     states: NULL
#>     states_abbr: NULL
#>     street_address: function () 
#>     street_address_formats: {{street_name}} {{building_number}}
#>     street_name: function () 
#>     street_name_formats: {{first_name}}{{street_suffix}} {{last_name}}{{street_su ...
#>     street_suffix: function () 
#>     street_suffixes: kade straat laan hof weg steeg
#>   Private:
#>     locales: en_US en_GB en_NZ es_ES nl_NL
z$locale
#> [1] "nl_NL"
z$street_name()
#> [1] "Cadefausteeg"
z$postcode()
#> [1] "1553 ST"
z$city()
#> [1] "Groonentricht"