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] "BB4 8FY"
#> 
#> $quality
#> [1] 1
#> 
#> $eastings
#> [1] 380642
#> 
#> $northings
#> [1] 427309
#> 
#> $country
#> [1] "England"
#> 
#> $nhs_ha
#> [1] "North West"
#> 
#> $longitude
#> [1] -2.294976
#> 
#> $latitude
#> [1] 53.74181
#> 
#> $european_electoral_region
#> [1] "North West"
#> 
#> $primary_care_trust
#> [1] "East Lancashire Teaching"
#> 
#> $region
#> [1] "North West"
#> 
#> $lsoa
#> [1] "Rossendale 001C"
#> 
#> $msoa
#> [1] "Rossendale 001"
#> 
#> $incode
#> [1] "8FY"
#> 
#> $outcode
#> [1] "BB4"
#> 
#> $parliamentary_constituency
#> [1] "Rossendale and Darwen"
#> 
#> $parliamentary_constituency_2024
#> [1] "Rossendale and Darwen"
#> 
#> $admin_district
#> [1] "Rossendale"
#> 
#> $parish
#> [1] "Rossendale, unparished area"
#> 
#> $admin_county
#> [1] "Lancashire"
#> 
#> $date_of_introduction
#> [1] "201705"
#> 
#> $admin_ward
#> [1] "Goodshaw & Cribden"
#> 
#> $ced
#> [1] "Mid-Rossendale"
#> 
#> $ccg
#> [1] "NHS Lancashire and South Cumbria"
#> 
#> $nuts
#> [1] "Rossendale"
#> 
#> $pfa
#> [1] "Lancashire"
#> 
#> $codes
#> $codes$admin_district
#> [1] "E07000125"
#> 
#> $codes$admin_county
#> [1] "E10000017"
#> 
#> $codes$admin_ward
#> [1] "E05015819"
#> 
#> $codes$parish
#> [1] "E43000099"
#> 
#> $codes$parliamentary_constituency
#> [1] "E14001450"
#> 
#> $codes$parliamentary_constituency_2024
#> [1] "E14001450"
#> 
#> $codes$ccg
#> [1] "E38000050"
#> 
#> $codes$ccg_id
#> [1] "01A"
#> 
#> $codes$ced
#> [1] "E58000789"
#> 
#> $codes$nuts
#> [1] "TLD46"
#> 
#> $codes$lsoa
#> [1] "E01025362"
#> 
#> $codes$msoa
#> [1] "E02005278"
#> 
#> $codes$lau2
#> [1] "E07000125"
#> 
#> $codes$pfa
#> [1] "E23000003"
#> 
#> 
random_postcode("N1")
#> $postcode
#> [1] "N1 7RF"
#> 
#> $quality
#> [1] 1
#> 
#> $eastings
#> [1] 532489
#> 
#> $northings
#> [1] 182848
#> 
#> $country
#> [1] "England"
#> 
#> $nhs_ha
#> [1] "London"
#> 
#> $longitude
#> [1] -0.091418
#> 
#> $latitude
#> [1] 51.52901
#> 
#> $european_electoral_region
#> [1] "London"
#> 
#> $primary_care_trust
#> [1] "City and Hackney Teaching"
#> 
#> $region
#> [1] "London"
#> 
#> $lsoa
#> [1] "Hackney 026A"
#> 
#> $msoa
#> [1] "Hackney 026"
#> 
#> $incode
#> [1] "7RF"
#> 
#> $outcode
#> [1] "N1"
#> 
#> $parliamentary_constituency
#> [1] "Hackney South and Shoreditch"
#> 
#> $parliamentary_constituency_2024
#> [1] "Hackney South and Shoreditch"
#> 
#> $admin_district
#> [1] "Hackney"
#> 
#> $parish
#> [1] "Hackney, unparished area"
#> 
#> $admin_county
#> NULL
#> 
#> $date_of_introduction
#> [1] "199501"
#> 
#> $admin_ward
#> [1] "Hoxton West"
#> 
#> $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] "E05009378"
#> 
#> $codes$parish
#> [1] "E43000202"
#> 
#> $codes$parliamentary_constituency
#> [1] "E14001260"
#> 
#> $codes$parliamentary_constituency_2024
#> [1] "E14001260"
#> 
#> $codes$ccg
#> [1] "E38000255"
#> 
#> $codes$ccg_id
#> [1] "A3A8R"
#> 
#> $codes$ced
#> [1] "E99999999"
#> 
#> $codes$nuts
#> [1] "TLI41"
#> 
#> $codes$lsoa
#> [1] "E01001779"
#> 
#> $codes$msoa
#> [1] "E02000370"
#> 
#> $codes$lau2
#> [1] "E09000012"
#> 
#> $codes$pfa
#> [1] "E23000001"
#> 
#> 
# }