phsopendata
Functions to extract and interact with data from the Scottish Health and Social Care Open Data platform.
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (18.8%) to scientific vocabulary
Keywords
r-package
Last synced: 10 months ago
·
JSON representation
Repository
Functions to extract and interact with data from the Scottish Health and Social Care Open Data platform.
Basic Info
- Host: GitHub
- Owner: Public-Health-Scotland
- Language: R
- Default Branch: master
- Homepage: https://public-health-scotland.github.io/phsopendata/
- Size: 5.31 MB
Statistics
- Stars: 10
- Watchers: 2
- Forks: 3
- Open Issues: 6
- Releases: 4
Topics
r-package
Created almost 5 years ago
· Last pushed 10 months ago
Metadata Files
Readme
Changelog
README.Rmd
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# phsopendata
[](https://CRAN.R-project.org/package=phsopendata)
[](https://github.com/Public-Health-Scotland/phsopendata/releases/latest)
[](https://github.com/Public-Health-Scotland/phsopendata/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/Public-Health-Scotland/phsopendata?branch=master)
`phsopendata` contains functions to interact with open data from the [Scottish Health and Social Care Open Data platform](https://www.opendata.nhs.scot/) via the CKAN API.
- `get_resource()` extracts a single resource from an open dataset by resource id
- `get_latest_resource()` extracts the most recent resource from applicable datasets, by dataset name
- `get_dataset()` extracts multiple resources from an open dataset by dataset name
- `list_datasets()` returns the names of all available datasets
- `list_resources()` returns information on all resources within an open dataset by dataset name
`phsopendata` can be used on both Posit Workbench and desktop versions of RStudio.
## Installation
```{r, eval = FALSE}
# The easiest way to get phsopendata is to install from CRAN:
install.packages("phsopendata")
```
### Development version
To get a bug fix or to use a feature from the development version, you can install
the development version of phsopendata from GitHub.
```{r, eval = FALSE}
# install.packages("remotes")
remotes::install_github("Public-Health-Scotland/phsopendata")
```
## Examples
### Downloading a data table with `get_resource()`
To extract a specific resource, you will need its unique identifier - resource id. This can be found in the dataset metadata, the URL of a resource's page on https://www.opendata.nhs.scot/, or extracted using `list_resources()`.
```{r example resource, eval = FALSE}
library(phsopendata)
# define a resource ID
res_id <- "a794d603-95ab-4309-8c92-b48970478c14"
# download the data from the CKAN database
data <- get_resource(res_id = "a794d603-95ab-4309-8c92-b48970478c14")
```
### Querying/filtering data with `get_resource()`
You can define a row limit with the `rows` argument to get the first *N* rows of a table.
```{r example row, eval = FALSE}
# get first 100 rows
get_resource(
res_id = "a794d603-95ab-4309-8c92-b48970478c14",
rows = 100
)
```
You can use `col_select` and `row_filters` to query the data server-side (i.e., the data is filtered before it is downloaded to your machine).
```{r example query, eval = FALSE}
# get first 100 rows
get_resource(
res_id = "a794d603-95ab-4309-8c92-b48970478c14",
col_select = c("GPPracticeName", "TelephoneNumber"),
row_filters = list(
HB = "S08000017",
Dispensing = "Y"
)
)
```
### Downloading multiple tables with `get_dataset()`
To extract all resources from a dataset, you will need to use the *dataset name*. Note that this will differ from the *dataset title* that displays on the website. This can be found using `list_datasets()`, or taken from the dataset URL.
In this example, we are downloading GP Practice Population Demographics from: [opendata.nhs.scot/dataset/*gp-practice-populations*](https://www.opendata.nhs.scot/dataset/gp-practice-populations), so the dataset name will be gp-practice-populations.
```{r example dataset, eval = FALSE}
# if max_resources is not set, all resources will be returned by default.
# Here we pull 10 rows from the first 2 resources only
get_dataset("gp-practice-populations", max_resources = 2, rows = 10)
```
## Contributing to phsopendata
At present, this package is maintained by [Csilla Scharle](https://github.com/csillasch).
If you have requests or suggestions for additional functionality, please contact the package maintainer and/or the [PHS Open Data team](mailto:phs.opendata@phs.scot).
If you would like to share examples of how you work with open data, you can also do so in the [Open Data repository](https://github.com/Public-Health-Scotland/Open-Data), where example scripts and resources are collated.
Owner
- Name: Public Health Scotland
- Login: Public-Health-Scotland
- Kind: organization
- Email: phs.transformingpublishing@phs.scot
- Website: https://publichealthscotland.scot/
- Twitter: p_h_s_official
- Repositories: 38
- Profile: https://github.com/Public-Health-Scotland
GitHub Events
Total
- Create event: 28
- Release event: 3
- Issues event: 4
- Watch event: 2
- Delete event: 24
- Issue comment event: 26
- Push event: 104
- Pull request review comment event: 1
- Pull request event: 56
- Pull request review event: 30
Last Year
- Create event: 28
- Release event: 3
- Issues event: 4
- Watch event: 2
- Delete event: 24
- Issue comment event: 26
- Push event: 104
- Pull request review comment event: 1
- Pull request event: 56
- Pull request review event: 30
Issues and Pull Requests
Last synced: 10 months ago
All Time
- Total issues: 10
- Total pull requests: 105
- Average time to close issues: about 1 year
- Average time to close pull requests: about 2 months
- Total issue authors: 5
- Total pull request authors: 5
- Average comments per issue: 1.1
- Average comments per pull request: 0.67
- Merged pull requests: 71
- Bot issues: 1
- Bot pull requests: 31
Past Year
- Issues: 4
- Pull requests: 57
- Average time to close issues: 6 days
- Average time to close pull requests: 15 days
- Issue authors: 2
- Pull request authors: 3
- Average comments per issue: 0.75
- Average comments per pull request: 0.54
- Merged pull requests: 36
- Bot issues: 1
- Bot pull requests: 20
Top Authors
Issue Authors
- Moohan (6)
- datagestive (1)
- johnmackintosh (1)
- ciarag01 (1)
- dependabot[bot] (1)
Pull Request Authors
- Moohan (54)
- dependabot[bot] (31)
- csillasch (11)
- ross-hull (5)
- daikman (4)
Top Labels
Issue Labels
enhancement (1)
CKAN issue (1)
dependencies (1)
Pull Request Labels
dependencies (31)
github_actions (3)
documentation (3)
Packages
- Total packages: 1
- Total downloads: unknown
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 1
- Total maintainers: 1
cran.r-project.org: phsopendata
Extract from the Scottish Health and Social Care Open Data Platform
- Homepage: https://github.com/Public-Health-Scotland/phsopendata
- Documentation: http://cran.r-project.org/web/packages/phsopendata/phsopendata.pdf
- License: MIT + file LICENSE
-
Latest release: 1.0.0
published 10 months ago
Rankings
Dependent packages count: 25.6%
Dependent repos count: 31.5%
Average: 47.5%
Downloads: 85.4%
Maintainers (1)
Last synced:
10 months ago
Dependencies
DESCRIPTION
cran
- cli * imports
- dplyr >= 1.0.0 imports
- glue >= 1.0.0 imports
- httr >= 1.0.0 imports
- jsonlite >= 1.0.0 imports
- magrittr >= 1.0.0 imports
- purrr * imports
- readr >= 1.0.0 imports
- stringdist * imports
- tibble >= 3.0.0 imports
- xml2 * imports
- testthat >= 3.0.0 suggests
.github/workflows/render-README.yml
actions
- actions/checkout v2 composite
- r-lib/actions/setup-pandoc v1 composite
- r-lib/actions/setup-r v1 composite
.github/workflows/R-CMD-check.yaml
actions
- actions/checkout v3 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/document.yaml
actions
- actions/checkout v3 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/lint.yaml
actions
- actions/checkout v3 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pkgdown.yaml
actions
- JamesIves/github-pages-deploy-action v4.4.1 composite
- actions/checkout v3 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/style.yaml
actions
- actions/cache v3 composite
- actions/checkout v3 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/test-coverage.yaml
actions
- actions/checkout v3 composite
- actions/upload-artifact v3 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite