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] "PO8 8AD"
#> 
#> $quality
#> [1] 1
#> 
#> $eastings
#> [1] 469420
#> 
#> $northings
#> [1] 110716
#> 
#> $country
#> [1] "England"
#> 
#> $nhs_ha
#> [1] "South Central"
#> 
#> $longitude
#> [1] -1.01435
#> 
#> $latitude
#> [1] 50.89176
#> 
#> $european_electoral_region
#> [1] "South East"
#> 
#> $primary_care_trust
#> [1] "Hampshire"
#> 
#> $region
#> [1] "South East"
#> 
#> $lsoa
#> [1] "Havant 020C"
#> 
#> $msoa
#> [1] "Havant 020"
#> 
#> $incode
#> [1] "8AD"
#> 
#> $outcode
#> [1] "PO8"
#> 
#> $parliamentary_constituency
#> [1] "Fareham and Waterlooville"
#> 
#> $parliamentary_constituency_2024
#> [1] "Fareham and Waterlooville"
#> 
#> $admin_district
#> [1] "Havant"
#> 
#> $parish
#> [1] "Havant, unparished area"
#> 
#> $admin_county
#> [1] "Hampshire"
#> 
#> $date_of_introduction
#> [1] "198001"
#> 
#> $admin_ward
#> [1] "Cowplain"
#> 
#> $ced
#> [1] "Cowplain & Hart Plain"
#> 
#> $ccg
#> [1] "NHS Hampshire and Isle of Wight"
#> 
#> $nuts
#> [1] "Havant"
#> 
#> $pfa
#> [1] "Hampshire"
#> 
#> $nhs_region
#> [1] "South East"
#> 
#> $ttwa
#> [1] "Portsmouth"
#> 
#> $national_park
#> [1] "England (non-National Park)"
#> 
#> $bua
#> [1] "Horndean"
#> 
#> $icb
#> [1] "NHS Hampshire and Isle of Wight Integrated Care Board"
#> 
#> $cancer_alliance
#> [1] "Wessex"
#> 
#> $lsoa11
#> [1] "Havant 020C"
#> 
#> $msoa11
#> [1] "Havant 020"
#> 
#> $lsoa21
#> [1] "Havant 020C"
#> 
#> $msoa21
#> [1] "Havant 020"
#> 
#> $oa21
#> [1] "E00116453"
#> 
#> $ruc11
#> [1] "(England/Wales) Urban city and town"
#> 
#> $ruc21
#> [1] "Urban: Nearer to a major town or city"
#> 
#> $lep1
#> [1] "Solent"
#> 
#> $lep2
#> NULL
#> 
#> $codes
#> $codes$admin_district
#> [1] "E07000090"
#> 
#> $codes$admin_county
#> [1] "E10000014"
#> 
#> $codes$admin_ward
#> [1] "E05015582"
#> 
#> $codes$parish
#> [1] "E43000072"
#> 
#> $codes$parliamentary_constituency
#> [1] "E14001233"
#> 
#> $codes$parliamentary_constituency_2024
#> [1] "E14001233"
#> 
#> $codes$ccg
#> [1] "E38000253"
#> 
#> $codes$ccg_id
#> [1] "D9Y0V"
#> 
#> $codes$ced
#> [1] "E58000548"
#> 
#> $codes$nuts
#> [1] "TLJ35"
#> 
#> $codes$lsoa
#> [1] "E01022921"
#> 
#> $codes$msoa
#> [1] "E02006831"
#> 
#> $codes$lau2
#> [1] "E07000090"
#> 
#> $codes$pfa
#> [1] "E23000030"
#> 
#> $codes$nhs_region
#> [1] "E40000005"
#> 
#> $codes$ttwa
#> [1] "E30000254"
#> 
#> $codes$national_park
#> [1] "E65000001"
#> 
#> $codes$bua
#> [1] "E63013569"
#> 
#> $codes$icb
#> [1] "E54000042"
#> 
#> $codes$cancer_alliance
#> [1] "E56000016"
#> 
#> $codes$lsoa11
#> [1] "E01022921"
#> 
#> $codes$msoa11
#> [1] "E02006831"
#> 
#> $codes$lsoa21
#> [1] "E01022921"
#> 
#> $codes$msoa21
#> [1] "E02006831"
#> 
#> $codes$oa21
#> [1] "E00116453"
#> 
#> $codes$ruc11
#> [1] "C1"
#> 
#> $codes$ruc21
#> [1] "UN1"
#> 
#> $codes$lep1
#> [1] "E37000055"
#> 
#> $codes$lep2
#> NULL
#> 
#> 
random_postcode("N1")
#> $postcode
#> [1] "N1 1WG"
#> 
#> $quality
#> [1] 1
#> 
#> $eastings
#> [1] 531630
#> 
#> $northings
#> [1] 183943
#> 
#> $country
#> [1] "England"
#> 
#> $nhs_ha
#> [1] "London"
#> 
#> $longitude
#> [1] -0.103385
#> 
#> $latitude
#> [1] 51.53905
#> 
#> $european_electoral_region
#> [1] "London"
#> 
#> $primary_care_trust
#> [1] "Islington"
#> 
#> $region
#> [1] "London"
#> 
#> $lsoa
#> [1] "Islington 020B"
#> 
#> $msoa
#> [1] "Islington 020"
#> 
#> $incode
#> [1] "1WG"
#> 
#> $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] "200705"
#> 
#> $admin_ward
#> [1] "St Mary's & St James'"
#> 
#> $ced
#> NULL
#> 
#> $ccg
#> [1] "NHS North Central London"
#> 
#> $nuts
#> [1] "Islington"
#> 
#> $pfa
#> [1] "Metropolitan Police"
#> 
#> $nhs_region
#> [1] "London"
#> 
#> $ttwa
#> [1] "London"
#> 
#> $national_park
#> [1] "England (non-National Park)"
#> 
#> $bua
#> [1] "Islington"
#> 
#> $icb
#> [1] "NHS North Central London Integrated Care Board"
#> 
#> $cancer_alliance
#> [1] "North Central London"
#> 
#> $lsoa11
#> [1] "Islington 020B"
#> 
#> $msoa11
#> [1] "Islington 020"
#> 
#> $lsoa21
#> [1] "Islington 020B"
#> 
#> $msoa21
#> [1] "Islington 020"
#> 
#> $oa21
#> [1] "E00013926"
#> 
#> $ruc11
#> [1] "(England/Wales) Urban major conurbation"
#> 
#> $ruc21
#> [1] "Urban: Nearer to a major town or city"
#> 
#> $lep1
#> [1] "London"
#> 
#> $lep2
#> NULL
#> 
#> $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] "E01002794"
#> 
#> $codes$msoa
#> [1] "E02000573"
#> 
#> $codes$lau2
#> [1] "E09000019"
#> 
#> $codes$pfa
#> [1] "E23000001"
#> 
#> $codes$nhs_region
#> [1] "E40000003"
#> 
#> $codes$ttwa
#> [1] "E30000234"
#> 
#> $codes$national_park
#> [1] "E65000001"
#> 
#> $codes$bua
#> [1] "E63011980"
#> 
#> $codes$icb
#> [1] "E54000028"
#> 
#> $codes$cancer_alliance
#> [1] "E56000027"
#> 
#> $codes$lsoa11
#> [1] "E01002794"
#> 
#> $codes$msoa11
#> [1] "E02000573"
#> 
#> $codes$lsoa21
#> [1] "E01002794"
#> 
#> $codes$msoa21
#> [1] "E02000573"
#> 
#> $codes$oa21
#> [1] "E00013926"
#> 
#> $codes$ruc11
#> [1] "A1"
#> 
#> $codes$ruc21
#> [1] "UN1"
#> 
#> $codes$lep1
#> [1] "E37000051"
#> 
#> $codes$lep2
#> NULL
#> 
#> 
# }