You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
library(tidyverse)
library(PostcodesioR)
library(NHSRpostcodetools) # installed from GitHub not CRAN
library(NHSRpopulation) # installed from GitHub not CRAN
library(janitor)
#>
#> Attaching package: 'janitor'
#> The following objects are masked from 'package:stats':
#>
#> chisq.test, fisher.test
# Generate random example postcodes
# Restricted to NG postcodes from Nottinghamshire because postcodes are drawn
# from all nations and don't validate within the {NHSRpopulation} package
# currently
postcodes <- purrr::map_chr(
1:10,
.f = ~ PostcodesioR::random_postcode("NG16") |>
purrr::pluck(1)
)
# Create a tibble
tibble_postcodes <- dplyr::tibble(
random_postcodes = postcodes,
)
NHSRpopulation::get_data(tibble_postcodes,
column = "random_postcodes",
url_type = "imd"
) |>
dplyr::select(
random_postcodes,
new_postcode,
imd_decile,
imd_rank,
imd_score
) |>
mutate(imd_decile_local = ntile(-imd_score, n = 10)) # creating new deciles from the data provided
#> Joining with `by = join_by(random_postcodes)`
#> Error in seq_len(ceiling(length(x)/batch_size)): argument must be coercible to non-negative integer
Created on 2024-10-21 with [reprex v2.1.1](https://reprex.tidyverse.org/)
And a simplified code:
NHSRpostcodetools::get_data(tibble_postcodes)
#> Error: 'get_data' is not an exported object from 'namespace:NHSRpostcodetools'
The text was updated successfully, but these errors were encountered:
Hi @Lextuga007 I am pretty sure this will be resulting from the fact that the IMD data endpoint used in NHSRpopulation::api_url no longer exists (or rather, it is currently reporting a "Token required" error message).
Let me know if you would like me to share some alternative code for getting the IMD data.
My suggestion would be that the IMD 2019 table should be stored as static internal package data in the package, as it is fixed data and doesn't need to be retrieved fresh from an API each time it is needed.
It's a bit annoying because the whole point of a data API endpoint is they're not supposed to just disappear! But I am sure there are reasons why they sometimes do.
This is what I'm using in my package here instead now:
From the Health Inequalities book:
And a simplified code:
The text was updated successfully, but these errors were encountered: