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] "WN8 9DU"
#> 
#> $quality
#> [1] 1
#> 
#> $eastings
#> [1] 350440
#> 
#> $northings
#> [1] 404770
#> 
#> $country
#> [1] "England"
#> 
#> $nhs_ha
#> [1] "North West"
#> 
#> $longitude
#> [1] -2.749255
#> 
#> $latitude
#> [1] 53.53723
#> 
#> $european_electoral_region
#> [1] "North West"
#> 
#> $primary_care_trust
#> [1] "Central Lancashire"
#> 
#> $region
#> [1] "North West"
#> 
#> $lsoa
#> [1] "West Lancashire 014C"
#> 
#> $msoa
#> [1] "West Lancashire 014"
#> 
#> $incode
#> [1] "9DU"
#> 
#> $outcode
#> [1] "WN8"
#> 
#> $parliamentary_constituency
#> [1] "West Lancashire"
#> 
#> $parliamentary_constituency_2024
#> [1] "West Lancashire"
#> 
#> $admin_district
#> [1] "West Lancashire"
#> 
#> $parish
#> [1] "West Lancashire, unparished area"
#> 
#> $admin_county
#> [1] "Lancashire"
#> 
#> $date_of_introduction
#> [1] "198001"
#> 
#> $admin_ward
#> [1] "Skelmersdale South"
#> 
#> $ced
#> [1] "Skelmersdale East"
#> 
#> $ccg
#> [1] "NHS Lancashire and South Cumbria"
#> 
#> $nuts
#> [1] "West Lancashire"
#> 
#> $pfa
#> [1] "Lancashire"
#> 
#> $codes
#> $codes$admin_district
#> [1] "E07000127"
#> 
#> $codes$admin_county
#> [1] "E10000017"
#> 
#> $codes$admin_ward
#> [1] "E05014940"
#> 
#> $codes$parish
#> [1] "E43000101"
#> 
#> $codes$parliamentary_constituency
#> [1] "E14001577"
#> 
#> $codes$parliamentary_constituency_2024
#> [1] "E14001577"
#> 
#> $codes$ccg
#> [1] "E38000200"
#> 
#> $codes$ccg_id
#> [1] "02G"
#> 
#> $codes$ced
#> [1] "E58000819"
#> 
#> $codes$nuts
#> [1] "TLD47"
#> 
#> $codes$lsoa
#> [1] "E01025503"
#> 
#> $codes$msoa
#> [1] "E02005317"
#> 
#> $codes$lau2
#> [1] "E07000127"
#> 
#> $codes$pfa
#> [1] "E23000003"
#> 
#> 
random_postcode("N1")
#> $postcode
#> [1] "N1 8QE"
#> 
#> $quality
#> [1] 1
#> 
#> $eastings
#> [1] 532058
#> 
#> $northings
#> [1] 183728
#> 
#> $country
#> [1] "England"
#> 
#> $nhs_ha
#> [1] "London"
#> 
#> $longitude
#> [1] -0.097324
#> 
#> $latitude
#> [1] 51.53702
#> 
#> $european_electoral_region
#> [1] "London"
#> 
#> $primary_care_trust
#> [1] "Islington"
#> 
#> $region
#> [1] "London"
#> 
#> $lsoa
#> [1] "Islington 018D"
#> 
#> $msoa
#> [1] "Islington 018"
#> 
#> $incode
#> [1] "8QE"
#> 
#> $outcode
#> [1] "N1"
#> 
#> $parliamentary_constituency
#> [1] "Islington South and Finsbury"
#> 
#> $parliamentary_constituency_2024
#> [1] "Islington South and Finsbury"
#> 
#> $admin_district
#> [1] "Islington"
#> 
#> $parish
#> [1] "Islington, unparished area"
#> 
#> $admin_county
#> NULL
#> 
#> $date_of_introduction
#> [1] "198001"
#> 
#> $admin_ward
#> [1] "St Mary's & St James'"
#> 
#> $ced
#> NULL
#> 
#> $ccg
#> [1] "NHS North Central London"
#> 
#> $nuts
#> [1] "Islington"
#> 
#> $pfa
#> [1] "Metropolitan Police"
#> 
#> $codes
#> $codes$admin_district
#> [1] "E09000019"
#> 
#> $codes$admin_county
#> [1] "E99999999"
#> 
#> $codes$admin_ward
#> [1] "E05013710"
#> 
#> $codes$parish
#> [1] "E43000209"
#> 
#> $codes$parliamentary_constituency
#> [1] "E14001306"
#> 
#> $codes$parliamentary_constituency_2024
#> [1] "E14001306"
#> 
#> $codes$ccg
#> [1] "E38000240"
#> 
#> $codes$ccg_id
#> [1] "93C"
#> 
#> $codes$ced
#> [1] "E99999999"
#> 
#> $codes$nuts
#> [1] "TLI43"
#> 
#> $codes$lsoa
#> [1] "E01002799"
#> 
#> $codes$msoa
#> [1] "E02000571"
#> 
#> $codes$lau2
#> [1] "E09000019"
#> 
#> $codes$pfa
#> [1] "E23000001"
#> 
#> 
# }