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] "BS34 7HF"
#> 
#> $quality
#> [1] 1
#> 
#> $eastings
#> [1] 360930
#> 
#> $northings
#> [1] 179061
#> 
#> $country
#> [1] "England"
#> 
#> $nhs_ha
#> [1] "South West"
#> 
#> $longitude
#> [1] -2.564357
#> 
#> $latitude
#> [1] 51.50912
#> 
#> $european_electoral_region
#> [1] "South West"
#> 
#> $primary_care_trust
#> [1] "South Gloucestershire"
#> 
#> $region
#> [1] "South West"
#> 
#> $lsoa
#> [1] "South Gloucestershire 018A"
#> 
#> $msoa
#> [1] "South Gloucestershire 018"
#> 
#> $incode
#> [1] "7HF"
#> 
#> $outcode
#> [1] "BS34"
#> 
#> $parliamentary_constituency
#> [1] "Filton and Bradley Stoke"
#> 
#> $parliamentary_constituency_2024
#> [1] "Filton and Bradley Stoke"
#> 
#> $admin_district
#> [1] "South Gloucestershire"
#> 
#> $parish
#> [1] "Filton"
#> 
#> $admin_county
#> NULL
#> 
#> $date_of_introduction
#> [1] "199712"
#> 
#> $admin_ward
#> [1] "Filton"
#> 
#> $ced
#> NULL
#> 
#> $ccg
#> [1] "NHS Bristol, North Somerset and South Gloucestershire"
#> 
#> $nuts
#> [1] "South Gloucestershire"
#> 
#> $pfa
#> [1] "Avon and Somerset"
#> 
#> $nhs_region
#> [1] "South West"
#> 
#> $ttwa
#> [1] "Bristol"
#> 
#> $national_park
#> [1] "England (non-National Park)"
#> 
#> $bua
#> [1] "Filton"
#> 
#> $icb
#> [1] "NHS Bristol, North Somerset and South Gloucestershire Integrated Care Board"
#> 
#> $cancer_alliance
#> [1] "Somerset, Wiltshire, Avon and Gloucestershire"
#> 
#> $lsoa11
#> [1] "South Gloucestershire 018A"
#> 
#> $msoa11
#> [1] "South Gloucestershire 018"
#> 
#> $lsoa21
#> [1] "South Gloucestershire 018A"
#> 
#> $msoa21
#> [1] "South Gloucestershire 018"
#> 
#> $oa21
#> [1] "E00075320"
#> 
#> $ruc11
#> [1] "(England/Wales) Urban city and town"
#> 
#> $ruc21
#> [1] "Urban: Nearer to a major town or city"
#> 
#> $lep1
#> [1] "West of England"
#> 
#> $lep2
#> NULL
#> 
#> $codes
#> $codes$admin_district
#> [1] "E06000025"
#> 
#> $codes$admin_county
#> [1] "E99999999"
#> 
#> $codes$admin_ward
#> [1] "E05012113"
#> 
#> $codes$parish
#> [1] "E04001052"
#> 
#> $codes$parliamentary_constituency
#> [1] "E14001237"
#> 
#> $codes$parliamentary_constituency_2024
#> [1] "E14001237"
#> 
#> $codes$ccg
#> [1] "E38000222"
#> 
#> $codes$ccg_id
#> [1] "15C"
#> 
#> $codes$ced
#> [1] "E99999999"
#> 
#> $codes$nuts
#> [1] "TLK52"
#> 
#> $codes$lsoa
#> [1] "E01014904"
#> 
#> $codes$msoa
#> [1] "E02003107"
#> 
#> $codes$lau2
#> [1] "E06000025"
#> 
#> $codes$pfa
#> [1] "E23000036"
#> 
#> $codes$nhs_region
#> [1] "E40000006"
#> 
#> $codes$ttwa
#> [1] "E30000180"
#> 
#> $codes$national_park
#> [1] "E65000001"
#> 
#> $codes$bua
#> [1] "E63012058"
#> 
#> $codes$icb
#> [1] "E54000039"
#> 
#> $codes$cancer_alliance
#> [1] "E56000033"
#> 
#> $codes$lsoa11
#> [1] "E01014904"
#> 
#> $codes$msoa11
#> [1] "E02003107"
#> 
#> $codes$lsoa21
#> [1] "E01014904"
#> 
#> $codes$msoa21
#> [1] "E02003107"
#> 
#> $codes$oa21
#> [1] "E00075320"
#> 
#> $codes$ruc11
#> [1] "C1"
#> 
#> $codes$ruc21
#> [1] "UN1"
#> 
#> $codes$lep1
#> [1] "E37000037"
#> 
#> $codes$lep2
#> NULL
#> 
#> 
random_postcode("N1")
#> $postcode
#> [1] "N1 2RE"
#> 
#> $quality
#> [1] 1
#> 
#> $eastings
#> [1] 532564
#> 
#> $northings
#> [1] 184731
#> 
#> $country
#> [1] "England"
#> 
#> $nhs_ha
#> [1] "London"
#> 
#> $longitude
#> [1] -0.089629
#> 
#> $latitude
#> [1] 51.54591
#> 
#> $european_electoral_region
#> [1] "London"
#> 
#> $primary_care_trust
#> [1] "Islington"
#> 
#> $region
#> [1] "London"
#> 
#> $lsoa
#> [1] "Islington 014A"
#> 
#> $msoa
#> [1] "Islington 014"
#> 
#> $incode
#> [1] "2RE"
#> 
#> $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] "Canonbury"
#> 
#> $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 014A"
#> 
#> $msoa11
#> [1] "Islington 014"
#> 
#> $lsoa21
#> [1] "Islington 014A"
#> 
#> $msoa21
#> [1] "Islington 014"
#> 
#> $oa21
#> [1] "E00013526"
#> 
#> $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] "E05013701"
#> 
#> $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] "E01002716"
#> 
#> $codes$msoa
#> [1] "E02000567"
#> 
#> $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] "E01002716"
#> 
#> $codes$msoa11
#> [1] "E02000567"
#> 
#> $codes$lsoa21
#> [1] "E01002716"
#> 
#> $codes$msoa21
#> [1] "E02000567"
#> 
#> $codes$oa21
#> [1] "E00013526"
#> 
#> $codes$ruc11
#> [1] "A1"
#> 
#> $codes$ruc21
#> [1] "UN1"
#> 
#> $codes$lep1
#> [1] "E37000051"
#> 
#> $codes$lep2
#> NULL
#> 
#> 
# }