Description Usage Arguments Details Value Examples
postcode
takes a character string or vector of character
strings. It extracts the input values which adhere to the standard UK
postcode format (with or without spaces), assigns the appropriate amount
of spacing to them (for both pc7 and pc8 formats) and ensures all letters
are capitalised.
1 |
string |
A character string or vector of character strings. Input values which adhere to the standard UK postcode format may be upper or lower case and will be formatted regardless of existing spacing. Any input values which do not adhere to the standard UK postcode format will generate an NA and a warning message - see Value section for more information. |
format |
A character string denoting the desired output format. Valid options are 'pc7' and 'pc8'. The default is 'pc7'. See Value section for more information on the string length of output values. |
The standard UK postcode format (without spaces) is:
1 or 2 letters, followed by
1 number, followed by
1 optional letter or number, followed by
1 number, followed by
2 letters
UK government regulations
mandate which letters and numbers can be used in specific sections of a
postcode. However, these regulations are liable to change over time. For
this reason, postcode
does not validate whether a given postcode
actually exists, or whether specific numbers and letters are being used in
the appropriate places. It only assesses whether the given input is
consistent with the above format and, if so, assigns the appropriate amount
of spacing and capitalises any lower case letters.
When format
is set equal to pc7
, postcode
returns a character string of length 7. 5 character postcodes have two
spaces after the 2nd character; 6 character postcodes have 1 space after the
3rd character; and 7 character postcodes have no spaces.
When format
is set equal to pc8
, postcode
returns a
character string with maximum length 8. All postcodes, whether 5, 6 or 7
characters, have one space before the last 3 characters.
Any input values which do not adhere to the standard UK postcode format will generate an NA output value and a warning message. A warning is generated rather than an error so as not to let one erroneously recorded postcode in a large input vector prevent the remaining entries from being appropriately formatted.
Any input values which do adhere to the standard UK postcode format but contain lower case letters will generate a warning message explaining that these letters will be capitalised.
1 2 3 4 5 6 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.