Title: | Load 'CDRC' Data |
---|---|
Description: | A wrapper for the 'CDRC' 'API' that returns data frames or 'sf' of 'CDRC' data. The 'API' web reference is:<https://api.cdrc.ac.uk/swagger/index.html>. |
Authors: | Alessia Calafiore [aut, cre] |
Maintainer: | Alessia Calafiore <[email protected]> |
License: | GPL-3 |
Version: | 0.1.1 |
Built: | 2024-12-15 07:39:39 UTC |
Source: | CRAN |
Obtain data from the CDRC datasets. To find out what datasets are available and their respective dataCode run listCDRC()
.
getCDRC( dataCode, geography = c("postcode", "MSOA", "LSOA", "LAD", "LADname"), geographyCode, boundaries = FALSE )
getCDRC( dataCode, geography = c("postcode", "MSOA", "LSOA", "LAD", "LADname"), geographyCode, boundaries = FALSE )
dataCode |
A character-string API identifier associated which each dataset in the CDRC. To find out the dataCode of your desired dataset run |
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. |
A dataframe or sf depending whether boundaries are set to FALSE or TRUE respectively.
## Not run: ahah_data <- getCDRC("AHAHOverallIndexDomain",geography = "postcode", geographyCode = c("CH430UQ","LS61EF","L83UL"), boundaries = TRUE) View(ahah_data) plot(ahah_data$geometry) ## End(Not run)
## Not run: ahah_data <- getCDRC("AHAHOverallIndexDomain",geography = "postcode", geographyCode = c("CH430UQ","LS61EF","L83UL"), boundaries = TRUE) View(ahah_data) plot(ahah_data$geometry) ## End(Not run)
This function returns a list of all CDRC datasets that can be retrieved with this package. This function takes no arguments.
listCDRC()
listCDRC()
A dataframe of the datasets available to request with the API.
## Not run: dataset_list <- listCDRC() View(dataset_list) ## End(Not run)
## Not run: dataset_list <- listCDRC() View(dataset_list) ## End(Not run)
A dataset containing Lower Layer Super Output Areas in Liverpool Local Authority
liverpool
liverpool
A simple feature object with 297 rows and 7 variables:
Geographical Feature ID
LSOA Codes
LSOA Names
LSOA Names in Welsh
LSOA Area
LSOA Length
Simple Feature Geometry
https://geoportal.statistics.gov.uk/
This function will log in a CDRC user based on the username and password. If you do not have a CDRC user yet, please register on https://apps.cdrc.ac.uk/datasetportal/Identity/Account/Register When you log in an api token is automatically generated, saved in your R environment and loaded, no further action is required from you to access the API.
loginCDRC(username, password)
loginCDRC(username, password)
username |
A character-string with your CDRC username. |
password |
A character-string with your CDRC password. |
For safety reasons the API token will expire in 24h. This means that after 24h you need to log in again to generate a new API token which will be self-updated and load.
A response message which confirms the login was successful and how to see the API key.
## Not run: loginCDRC(name='your-username',password='your-password') ## End(Not run)
## Not run: loginCDRC(name='your-username',password='your-password') ## End(Not run)