View source: R/postcode_matching.R
index_postcodes | R Documentation |
Creates an index of a postcode database file using the first letters and first number from within the postcode. This has been designed for use with the NSPL database of UK postcodes and will not work for postcodes which do not start with letters followed by numbers.
index_postcodes(postcode_path, colname, name, exclude)
postcode_path |
path to folder containing multiple postcode csv files or a single csv file. Eg for ONS NSPL this could be either file.path("NSPL_FEB_2019_UK", "Data", "multi_csv") from where the ONS data was extracted if using the multi_csv files or file.path("NSPL_FEB_2019_UK", "Data", "NSPL_FEB_2019_UK.csv") if using the full database file. Using multi_csv files can overcome insufficient memory barriers. |
colname |
column name within database csv file(s) with postcode for postcode matching (optional). Default is the first column name within the database. |
name |
name to call the index (optional). Default is "Index". |
exclude |
string pattern within files to exclude when using a folder as postcode_path (optional). |
Returns a postcode database Index using the first letters from the file names and the first digits of the numbers within the postcodes as a data.frame object. Saves the Index file to the location of the postcode database.
Diane Hatziioanou
# Index <- index_postcodes(postcode_path)
# Index_ONS <- index_postcodes("C:/.../NSPL_FEB_2019_UK/Data/multi_csv/)
# Index_ONS <- index_postcodes(
# file.path(path, "NSPL_FEB_2019_UK, "Data ,"multi_csv"),
# exclude = "Readme.csv")
# Index_file <- index_postcodes(file.path(path, "2020 database, "Reference.csv"),
# colname = "pcd", name = "Reference_index")
# Create an index if necessary or read in if already there
# if (!file.exists(file.path(NSPL_csvs,"Index.csv"))) {
# Index <- index_postcodes(NSPL_csvs)
# } else {
# Index <- fread(file.path(NSPL_csvs,"Index.csv"))
# }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.