Learn R Programming

cdrcR (version 0.1.1)

getCDRC: Get data from the CDRC

Description

Obtain data from the CDRC datasets. To find out what datasets are available and their respective dataCode run listCDRC().

Usage

getCDRC(
  dataCode,
  geography = c("postcode", "MSOA", "LSOA", "LAD", "LADname"),
  geographyCode,
  boundaries = FALSE
)

Value

A dataframe or sf depending whether boundaries are set to FALSE or TRUE respectively.

Arguments

dataCode

A character-string API identifier associated which each dataset in the CDRC. To find out the dataCode of your desired dataset run listCDRC().

geography

The geographical levels in which the data can be retrieved. It can be postcode, MSOA, LSOA, LAD or LADname. Note that the geography in which the data are retrieved does not necessarily correspond with the geography of the data. For example, it is possible to query data of the AHAH index by postcodes although the index is originally at LSOA level. Therefore you will see returned the LSOAs that better match the required postcodes.

geographyCode

A character-vector of one or more postcodes, LSOA codes, MSOA codes, LAD codes or LAD names.

boundaries

if FALSE (the default), returns a data frame of the desired data. if TRUE, uses the Open Geography Portal API to return an sf with the 'geometry' column.

Examples

Run this code
if (FALSE) {
ahah_data <- getCDRC("AHAHOverallIndexDomain",geography = "postcode",
geographyCode = c("CH430UQ","LS61EF","L83UL"), boundaries = TRUE)
View(ahah_data)
plot(ahah_data$geometry)
}

Run the code above in your browser using DataLab