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] "KY5 0YY"
#> 
#> $quality
#> [1] 1
#> 
#> $eastings
#> [1] 323552
#> 
#> $northings
#> [1] 698567
#> 
#> $country
#> [1] "Scotland"
#> 
#> $nhs_ha
#> [1] "Fife"
#> 
#> $longitude
#> [1] -3.232872
#> 
#> $latitude
#> [1] 56.17359
#> 
#> $european_electoral_region
#> [1] "Scotland"
#> 
#> $primary_care_trust
#> [1] "Dunfermline and West Fife Community Health Partnership"
#> 
#> $region
#> NULL
#> 
#> $lsoa
#> [1] "Kinglassie East"
#> 
#> $msoa
#> [1] "Thornton and Kinglassie"
#> 
#> $incode
#> [1] "0YY"
#> 
#> $outcode
#> [1] "KY5"
#> 
#> $parliamentary_constituency
#> [1] "Glenrothes and Mid Fife"
#> 
#> $parliamentary_constituency_2024
#> [1] "Glenrothes and Mid Fife"
#> 
#> $admin_district
#> [1] "Fife"
#> 
#> $parish
#> NULL
#> 
#> $admin_county
#> NULL
#> 
#> $date_of_introduction
#> [1] "200710"
#> 
#> $admin_ward
#> [1] "Glenrothes West and Kinglassie"
#> 
#> $ced
#> NULL
#> 
#> $ccg
#> [1] "Dunfermline & West Fife Community Health Partnership"
#> 
#> $nuts
#> [1] "Fife"
#> 
#> $pfa
#> [1] "Scotland"
#> 
#> $nhs_region
#> NULL
#> 
#> $ttwa
#> [1] "Dunfermline and Kirkcaldy"
#> 
#> $national_park
#> NULL
#> 
#> $bua
#> NULL
#> 
#> $icb
#> NULL
#> 
#> $cancer_alliance
#> NULL
#> 
#> $lsoa11
#> [1] "Kinglassie East"
#> 
#> $msoa11
#> [1] "Thornton and Kinglassie"
#> 
#> $lsoa21
#> [1] "Kinglassie East"
#> 
#> $msoa21
#> [1] "Thornton and Kinglassie"
#> 
#> $oa21
#> [1] "S00154824"
#> 
#> $ruc11
#> [1] "(Scotland) Accessible Rural"
#> 
#> $ruc21
#> [1] "Accessible Rural"
#> 
#> $lep1
#> NULL
#> 
#> $lep2
#> NULL
#> 
#> $codes
#> $codes$admin_district
#> [1] "S12000047"
#> 
#> $codes$admin_county
#> [1] "S99999999"
#> 
#> $codes$admin_ward
#> [1] "S13003129"
#> 
#> $codes$parish
#> [1] "S99999999"
#> 
#> $codes$parliamentary_constituency
#> [1] "S14000090"
#> 
#> $codes$parliamentary_constituency_2024
#> [1] "S14000090"
#> 
#> $codes$ccg
#> [1] "S03000006"
#> 
#> $codes$ccg_id
#> [1] "006"
#> 
#> $codes$ced
#> [1] "S99999999"
#> 
#> $codes$nuts
#> [1] "TLM01"
#> 
#> $codes$lsoa
#> [1] "S01016664"
#> 
#> $codes$msoa
#> [1] "S02003093"
#> 
#> $codes$lau2
#> [1] "S30000042"
#> 
#> $codes$pfa
#> [1] "S23000009"
#> 
#> $codes$nhs_region
#> [1] "S99999999"
#> 
#> $codes$ttwa
#> [1] "S22000057"
#> 
#> $codes$national_park
#> [1] "S99999999"
#> 
#> $codes$bua
#> [1] "S99999999"
#> 
#> $codes$icb
#> [1] "S99999999"
#> 
#> $codes$cancer_alliance
#> [1] "S99999999"
#> 
#> $codes$lsoa11
#> [1] "S01009546"
#> 
#> $codes$msoa11
#> [1] "S02001798"
#> 
#> $codes$lsoa21
#> [1] "S01016664"
#> 
#> $codes$msoa21
#> [1] "S02003093"
#> 
#> $codes$oa21
#> [1] "S00154824"
#> 
#> $codes$ruc11
#> [1] "6"
#> 
#> $codes$ruc21
#> [1] "5"
#> 
#> $codes$lep1
#> [1] "S99999999"
#> 
#> $codes$lep2
#> NULL
#> 
#> 
random_postcode("N1")
#> $postcode
#> [1] "N1 1UB"
#> 
#> $quality
#> [1] 1
#> 
#> $eastings
#> [1] 531518
#> 
#> $northings
#> [1] 184243
#> 
#> $country
#> [1] "England"
#> 
#> $nhs_ha
#> [1] "London"
#> 
#> $longitude
#> [1] -0.104887
#> 
#> $latitude
#> [1] 51.54177
#> 
#> $european_electoral_region
#> [1] "London"
#> 
#> $primary_care_trust
#> [1] "Islington"
#> 
#> $region
#> [1] "London"
#> 
#> $lsoa
#> [1] "Islington 016D"
#> 
#> $msoa
#> [1] "Islington 016"
#> 
#> $incode
#> [1] "1UB"
#> 
#> $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] "Laycock"
#> 
#> $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 016D"
#> 
#> $msoa11
#> [1] "Islington 016"
#> 
#> $lsoa21
#> [1] "Islington 016D"
#> 
#> $msoa21
#> [1] "Islington 016"
#> 
#> $oa21
#> [1] "E00013952"
#> 
#> $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] "E05013708"
#> 
#> $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] "E01002790"
#> 
#> $codes$msoa
#> [1] "E02000569"
#> 
#> $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] "E01002790"
#> 
#> $codes$msoa11
#> [1] "E02000569"
#> 
#> $codes$lsoa21
#> [1] "E01002790"
#> 
#> $codes$msoa21
#> [1] "E02000569"
#> 
#> $codes$oa21
#> [1] "E00013952"
#> 
#> $codes$ruc11
#> [1] "A1"
#> 
#> $codes$ruc21
#> [1] "UN1"
#> 
#> $codes$lep1
#> [1] "E37000051"
#> 
#> $codes$lep2
#> NULL
#> 
#> 
# }