cdrcR is an R wrapper to access the CDRC APIs endpointsand retrieve CDRC data programmatically. The package is designed to haveone main function –getCDRC – which allows users to getdata from all CDRC APIs endpoints. A list of the datasets that can beaccessed through these enpoints and their metadata is obtained byrunninglistCDRC(). Such list will also provide users witha dataset identifier –thedataCode– which will addressthe data request to the correct endpoint. Run?getCDRC() toaccess the function full documentation.
You can installcdrcR from CRAN running:
install.packages("cdrcR")The CRAN version currently does not retrieve OA boundaries. To getthose please install the development version. Data affected are MODUMand OA classification. You can install the development version ofcdrcR from Github using devtools running:
# install.packages("devtools")devtools::install_github("aelissa/cdrcR")To use the CDRC APIs you need to register to the CDRCHERE
Load the library.
library(cdrcR)Log-in with the username and password that you used when registeredto the CDRC.
loginCDRC(username="your-username",password="your-password")Then you can list the datasets available and the relative dataCodewhich identifies the API endpoint.
listCDRC()which will result in a data frame like the following extract:
| Title | DataCode | dataSetURL | GeographicalCoverage | GeographyLevel |
|---|---|---|---|---|
| Access to Healthy Assets & Hazards (AHAH) 2019 | AHAHInputs, AHAHOverallIndexDomain | https://data.cdrc.ac.uk/dataset/access-healthy-assets-hazards-ahah | GreatBritain | LSOA |
| Classification of Workplace Zones (COWZ) 2011 | COWZUK2011 | https://data.cdrc.ac.uk/dataset/classification-workplace-zones-cowz | UnitedKingdom | WZ |
| Index of Multiple Deprivation (IMD) 2019 | IMD2019 | https://data.cdrc.ac.uk/dataset/index-multiple-deprivation-imd | UnitedKingdom | LSOA |
| Internet User Classification (IUC) 2018 | IUC2018 | https://data.cdrc.ac.uk/dataset/internet-user-classification | GreatBritain | LSOA |
Pick theDataCode relative to the dataset you want toretrieve data about and use it as input for the dataCode parameter ingetCDRC (run?getCDRC() to see the detaileddocumentation).
Be aware that the API endpoints enable query for the followinggeographies: postcodes, LSOAs, MSOAs, LAD codes and LAD names. Not alldata are originally developed at these geography levels (you can findthe original geography level for each dataset) withlistCDRC()), therefore the areas that better overlap yourrequired geography will be returned.
###loginloginCDRC(username="your-username",password="your-password")###check dataCodelistCDRC()###get the AHAH index for postcodes L13AY,L82TJ,L83ULahah<-getCDRC("AHAHOverallIndexDomain",geography = "postcode", geographyCode = c("L13AY","L82TJ","L83UL"))###rank postcodes by AHAH index from best to worst performingahah[order(ahah$ahah),c("postCode","ahah")]# postCode ahah#3 L8 3UL 20.01734#2 L8 2TJ 23.04482#1 L1 3AY 45.91745###loginloginCDRC(username="your-username",password="your-password")###check dataCodelistCDRC()###get Liverpool LSOAsliverpool<-sf::st_as_sf(liverpool)###get IUC data with geographical boundariesiuc<-getCDRC("IUC2018",geography = "LSOA", geographyCode = liverpool$LSOA11CD, boundaries = TRUE)###map iuclibrary(ggplot2)ggplot()+geom_sf(aes(fill=grpLabel, group=grpLabel),iuc,show.legend = T,color="NA")+theme_void()+labs(fill="IUC groups")###loginloginCDRC(username="your-username",password="your-password")###check dataCodelistCDRC()###get the IMD data for Sheffieldimd<-getCDRC("IMD2019",geography = "LADname", geographyCode = c("Sheffield","Leeds"))