Skip to contents

Returns a random postcode and all available data for that postcode.

Usage

random_postcode(outcode = NULL)

Arguments

outcode

A string. Filters random postcodes by outcode. Returns null if invalid outcode. Optional.

Value

A list with a random postcode with corresponding characteristics.

See also

postcode_lookup for documentation.

Examples

# \donttest{
random_postcode()
#> $postcode
#> [1] "ST6 1LW"
#> 
#> $quality
#> [1] 1
#> 
#> $eastings
#> [1] 388245
#> 
#> $northings
#> [1] 350576
#> 
#> $country
#> [1] "England"
#> 
#> $nhs_ha
#> [1] "West Midlands"
#> 
#> $longitude
#> [1] -2.176817
#> 
#> $latitude
#> [1] 53.05231
#> 
#> $european_electoral_region
#> [1] "West Midlands"
#> 
#> $primary_care_trust
#> [1] "Stoke on Trent"
#> 
#> $region
#> [1] "West Midlands"
#> 
#> $lsoa
#> [1] "Stoke-on-Trent 008A"
#> 
#> $msoa
#> [1] "Stoke-on-Trent 008"
#> 
#> $incode
#> [1] "1LW"
#> 
#> $outcode
#> [1] "ST6"
#> 
#> $parliamentary_constituency
#> [1] "Stoke-on-Trent North"
#> 
#> $parliamentary_constituency_2024
#> [1] "Stoke-on-Trent North"
#> 
#> $admin_district
#> [1] "Stoke-on-Trent"
#> 
#> $parish
#> [1] "Stoke-on-Trent, unparished area"
#> 
#> $admin_county
#> NULL
#> 
#> $date_of_introduction
#> [1] "198001"
#> 
#> $admin_ward
#> [1] "Ford Green & Smallthorne"
#> 
#> $ced
#> NULL
#> 
#> $ccg
#> [1] "NHS Staffordshire and Stoke-on-Trent"
#> 
#> $nuts
#> [1] "Stoke-on-Trent"
#> 
#> $pfa
#> [1] "Staffordshire"
#> 
#> $codes
#> $codes$admin_district
#> [1] "E06000021"
#> 
#> $codes$admin_county
#> [1] "E99999999"
#> 
#> $codes$admin_ward
#> [1] "E05014570"
#> 
#> $codes$parish
#> [1] "E43000017"
#> 
#> $codes$parliamentary_constituency
#> [1] "E14001521"
#> 
#> $codes$parliamentary_constituency_2024
#> [1] "E14001521"
#> 
#> $codes$ccg
#> [1] "E38000175"
#> 
#> $codes$ccg_id
#> [1] "05W"
#> 
#> $codes$ced
#> [1] "E99999999"
#> 
#> $codes$nuts
#> [1] "TLG23"
#> 
#> $codes$lsoa
#> [1] "E01014246"
#> 
#> $codes$msoa
#> [1] "E02002958"
#> 
#> $codes$lau2
#> [1] "E06000021"
#> 
#> $codes$pfa
#> [1] "E23000015"
#> 
#> 
random_postcode("N1")
#> $postcode
#> [1] "N1 4EB"
#> 
#> $quality
#> [1] 1
#> 
#> $eastings
#> [1] 533151
#> 
#> $northings
#> [1] 184183
#> 
#> $country
#> [1] "England"
#> 
#> $nhs_ha
#> [1] "London"
#> 
#> $longitude
#> [1] -0.081402
#> 
#> $latitude
#> [1] 51.54085
#> 
#> $european_electoral_region
#> [1] "London"
#> 
#> $primary_care_trust
#> [1] "City and Hackney Teaching"
#> 
#> $region
#> [1] "London"
#> 
#> $lsoa
#> [1] "Hackney 021D"
#> 
#> $msoa
#> [1] "Hackney 021"
#> 
#> $incode
#> [1] "4EB"
#> 
#> $outcode
#> [1] "N1"
#> 
#> $parliamentary_constituency
#> [1] "Islington South and Finsbury"
#> 
#> $parliamentary_constituency_2024
#> [1] "Islington South and Finsbury"
#> 
#> $admin_district
#> [1] "Hackney"
#> 
#> $parish
#> [1] "Hackney, unparished area"
#> 
#> $admin_county
#> NULL
#> 
#> $date_of_introduction
#> [1] "198001"
#> 
#> $admin_ward
#> [1] "De Beauvoir"
#> 
#> $ced
#> NULL
#> 
#> $ccg
#> [1] "NHS North East London"
#> 
#> $nuts
#> [1] "Hackney"
#> 
#> $pfa
#> [1] "Metropolitan Police"
#> 
#> $codes
#> $codes$admin_district
#> [1] "E09000012"
#> 
#> $codes$admin_county
#> [1] "E99999999"
#> 
#> $codes$admin_ward
#> [1] "E05009371"
#> 
#> $codes$parish
#> [1] "E43000202"
#> 
#> $codes$parliamentary_constituency
#> [1] "E14001306"
#> 
#> $codes$parliamentary_constituency_2024
#> [1] "E14001306"
#> 
#> $codes$ccg
#> [1] "E38000255"
#> 
#> $codes$ccg_id
#> [1] "A3A8R"
#> 
#> $codes$ced
#> [1] "E99999999"
#> 
#> $codes$nuts
#> [1] "TLI41"
#> 
#> $codes$lsoa
#> [1] "E01001751"
#> 
#> $codes$msoa
#> [1] "E02000365"
#> 
#> $codes$lau2
#> [1] "E09000012"
#> 
#> $codes$pfa
#> [1] "E23000001"
#> 
#> 
# }