Movatterモバイル変換


[0]ホーム

URL:


cdrcR

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.

Installation

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")

Register to the CDRC

To use the CDRC APIs you need to register to the CDRCHERE

Usage

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:

TitleDataCodedataSetURLGeographicalCoverageGeographyLevel
Access to Healthy Assets & Hazards (AHAH) 2019AHAHInputs, AHAHOverallIndexDomainhttps://data.cdrc.ac.uk/dataset/access-healthy-assets-hazards-ahahGreatBritainLSOA
Classification of Workplace Zones (COWZ) 2011COWZUK2011https://data.cdrc.ac.uk/dataset/classification-workplace-zones-cowzUnitedKingdomWZ
Index of Multiple Deprivation (IMD) 2019IMD2019https://data.cdrc.ac.uk/dataset/index-multiple-deprivation-imdUnitedKingdomLSOA
Internet User Classification (IUC) 2018IUC2018https://data.cdrc.ac.uk/dataset/internet-user-classificationGreatBritainLSOA

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.

Examples

  1. Get the overall Access to Healthy Assets & Hazards (AHAH) indexfor the following postcodes: L13AY,L82TJ,L83UL For the Access to HealthyAssets & Hazards (AHAH) index you can chose to get either theindividual inputs (via AHAHInputs) or the overall domain index (viaAHAHOverallIndexDomain). In this example we are interested in theoverall index to rank the postcodes above by their level of access tohealthy assets and hazards. Please note that while the request is forpostcodes the data is at LSOA level, therefore the LSOAs that betteroverlap the requested postcodes 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
  1. Get the Internet User Classification across Liverpool having theLSOA codes and map it.
###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")
  1. Get the Index of Multiple Deprivation of Sheffield and Leeds LocalAuthority Districts.
###loginloginCDRC(username="your-username",password="your-password")###check dataCodelistCDRC()###get the IMD data for Sheffieldimd<-getCDRC("IMD2019",geography = "LADname", geographyCode = c("Sheffield","Leeds"))

[8]ページ先頭

©2009-2025 Movatter.jp