Skip to content

Commit

Permalink
Merge pull request #19 from Moohan/add_release_badge
Browse files Browse the repository at this point in the history
Add release badge
  • Loading branch information
Moohan authored Jan 10, 2024
2 parents 467f661 + e34728f commit 62cdd7b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 40 deletions.
3 changes: 2 additions & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ knitr::opts_chunk$set(
# phsopendata

<!-- badges: start -->
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/Public-Health-Scotland/phsopendata)](https://github.com/Public-Health-Scotland/phsopendata/releases/latest)
[![R-CMD-check](https://github.com/Public-Health-Scotland/phsopendata/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/Public-Health-Scotland/phsopendata/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/Public-Health-Scotland/phsopendata/branch/master/graph/badge.svg)](https://app.codecov.io/gh/Public-Health-Scotland/phsopendata?branch=master)
<!-- badges: end -->
Expand Down Expand Up @@ -95,7 +96,7 @@ get_dataset("gp-practice-populations", max_resources = 2, rows = 10)

## Contributing to phsopendata

At present, this package is maintained by [David Aikman](https://github.com/daikman).
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](phs.opendata@phs.scot).

Expand Down
85 changes: 46 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@

<!-- README.md is generated from README.Rmd. Please edit that file -->

phsopendata
===========
# phsopendata

<!-- badges: start -->

[![GitHub release (latest by
date)](https://img.shields.io/github/v/release/Public-Health-Scotland/phsopendata)](https://github.com/Public-Health-Scotland/phsopendata/releases/latest)
[![R-CMD-check](https://github.com/Public-Health-Scotland/phsopendata/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/Public-Health-Scotland/phsopendata/actions/workflows/R-CMD-check.yaml)
[![Codecov test
coverage](https://codecov.io/gh/Public-Health-Scotland/phsopendata/branch/master/graph/badge.svg)](https://app.codecov.io/gh/Public-Health-Scotland/phsopendata?branch=master)
Expand All @@ -27,60 +28,65 @@ For extracting metadata and search functionality, we recommend using the
RStudio. However, depending on firewall settings, proxy use may need to
be configured with `use_proxy()`.

Installation
------------
## Installation

You need to install `phsopendata` from GitHub, which requires a package
like `remotes` or `devtools`.

Using `remotes` you run this to install the package:

remotes::install_github("Public-Health-Scotland/phsopendata",
upgrade = "never"
)
``` r
remotes::install_github("Public-Health-Scotland/phsopendata",
upgrade = "never"
)
```

Examples
--------
## Examples

### Downloading a data table with `get_resource()`

To extract a specific resource, you will need it’s unique identifier -
resource id. This can be found in the dataset metadata, the URL of a
resource’s page on
<a href="https://www.opendata.nhs.scot/" class="uri">https://www.opendata.nhs.scot/</a>,
or extracted using `ckanr::package_show`.
resource’s page on <https://www.opendata.nhs.scot/>, or extracted using
`ckanr::package_show`.

library(phsopendata)
``` r
library(phsopendata)

# define a resource ID
res_id <- "a794d603-95ab-4309-8c92-b48970478c14"
# 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")
# 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.

# get first 100 rows
get_resource(
res_id = "a794d603-95ab-4309-8c92-b48970478c14",
rows = 100
)
``` r
# 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).

# 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"
)
)
``` r
# 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()`

Expand All @@ -94,15 +100,16 @@ 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.

# 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)
``` r
# 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
---------------------------
## Contributing to phsopendata

At present, this package is maintained by the [PHS Open Data
team](phs.opendata@phs.scot).
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
Expand Down

0 comments on commit 62cdd7b

Please sign in to comment.