Package 'NHSRpopulation'

Title: Indices of Multiple Deprivation (IMD) for England
Description: This package includes functions to retrieve the Indices of Multiple Deprivation (IMD) data from the ONS by LSOA, currently for England.
Authors: Zoë Turner [aut, cre] , Francis Barton [aut] , Milan Wiedemann [aut] , Chris Beeley [aut]
Maintainer: Zoë Turner <[email protected]>
License: MIT + file LICENSE
Version: 0.0.2
Built: 2024-11-20 04:35:45 UTC
Source: https://github.com/nhs-r-community/NHSRpopulation

Help Index


Getting data from the IMD api

Description

Only required for IMD as postcodes is routed through the NHSRpostcodetools package

Usage

api_url()

Value

dataset


Query information to restrict data returned

Description

This function queries the API based on the information required and returns ids as these have no restriction applied to them. The IMD API restricts to 2k records for example.

Postcode and LSOA parameters require data because bringing all the data from the Online_ONS_Postcode_Directory_Live will take too long and is often unnecessary.

Usage

get_data(
  data,
  url_type = c("postcode", "imd"),
  fix_invalid = TRUE,
  column = "default"
)

Arguments

data

dataframe or vector.The data that will connect to either the postcode API or imd API.

url_type

String defaults to postcode which returns information from Online_ONS_Postcode_Directory_Live to return Postcode information via the NHSRpostcodetools package. imd connects to Indices_of_Multiple_Deprivation_(IMD)_2019 to return IMD information.

fix_invalid

Boolean, default TRUE. Whether to try to fix any postcodes that are not found (potentially because they are terminated codes, or contain typos).

column

String. Default would mean the automatic connection of a column called postcode if postcode data is being expected or lsoa11 if imd data as requested via the parameter url_type = "imd".

Value

data frame


Function to check if a string is an LSOA code

Description

Function to check if a string is an LSOA code

Usage

is_lsoa(data)

Arguments

data

string

Value

Logical


Function to check if a string is a valid postcode regardless of its formatting.

Description

With or without one space is permitted. Does not work with data where two spaces are included with 6 character postcodes. From the MIT licenced package Rbduk https://github.com/sama-ds/Rbduk/blob/main/R/is_postcode.R

Usage

is_postcode(data)

Arguments

data

string

Value

Logical

Examples

is_postcode("SW1a2nP")
is_postcode("SW1a 2nP")