0

I have a dataframe (df) which includes a column titled "Home.Postcode" which contains UK postcodes. I want to create a new column in the dataframe with the corresponding lower super output area (LSOA) for each of these postcodes.

I then want to add another column which shows the index of multiple deprivation for each of the LSOAs, but I think I need to be able to get a column with the LSOAs first. I've attempted this with the code below, but get an error:

library(PostcodesioR)
Library(purrr)
LSOA <- bulk_postcode_lookup(df$Home.Postcode)
#Error in check_list_limit(postcodes) : 
  Please provide a list with postcodes.
df2 <- cbind(df, LSOA)
Jess
  • 11
  • 2

1 Answers1

1

You need to pass a list with a single element named postcodes:

library(PostcodesioR)

postcodes <- list(postcodes = c("PR30SG", "M456GN"))
bulk_postcode_lookup(postcodes) |> str(2)
#> List of 2
#>  $ :List of 2
#>   ..$ query : chr "PR30SG"
#>   ..$ result:List of 26
#>  $ :List of 2
#>   ..$ query : chr "M456GN"
#>   ..$ result:List of 26

This is show in the examples in ?bulk_postcode_lookup.

Mikko Marttila
  • 10,972
  • 18
  • 31