Skip to content

Instantly share code, notes, and snippets.

@martinctc
Created April 10, 2025 14:37
Show Gist options
  • Select an option

  • Save martinctc/45f01b71b0f90ac0a0dc73c661e1721e to your computer and use it in GitHub Desktop.

Select an option

Save martinctc/45f01b71b0f90ac0a0dc73c661e1721e to your computer and use it in GitHub Desktop.
[Convert postcodes to location] #R
library(tidyverse)
library(PostcodesioR)
# Customize with your own path
df_with_postcodes <- read_csv(
"path/data/postcodes.csv"
)
# Update with column name containing postcode
postcode_column <- df_with_postcodes[["postcode"]]
# Return result and convert to tibble
returned_df <-
postcode_column %>%
map_dfr(postcode_lookup) %>%
as_tibble()
# Save output to CSV
write_csv(
returned_df,
"path/data/postcodes_output.csv"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment