Skip to content

Commit f1b14b8

Browse files
authored
Merge pull request #48 from Public-Health-Scotland/update_readme
Overhaul the README
2 parents ed894f4 + 04f7301 commit f1b14b8

4 files changed

Lines changed: 135 additions & 11 deletions

File tree

DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ Config/roxygen2/version: 8.0.0
3131
Config/testthat/edition: 3
3232
Encoding: UTF-8
3333
LazyData: true
34+
RoxygenNote: 7.3.3

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
- Fixed a typo in the lookup path that meant the package wouldn't work on Windows (RStudio Desktop).
44
- Make the minimum required R version 4.1
5+
- Overhaul the README; fixed out of date information, and added more detail and examples.
56
- Metadata is now available! Currently, this is only for the Scottish Postcode Directory (`get_spd()`), but we will bring it to the other lookups soon, too. You can see the metadata by using `metadata()` on the lookup object, for example:
67
```r
78
spd <- get_spd()

README.Rmd

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,62 @@ The goal of phslookups is to provide helper functions to easily access and use l
2525

2626
## Installation
2727

28-
You can install the latest version of phslookups from [GitHub](https://github.com) with:
28+
If you are internal to PHS, you can install the latest version of phslookups from the internal Posit Package Manager.
29+
30+
``` r
31+
# On the Posit Workbench
32+
install.packages("phslookups")
33+
34+
# On RStudio Desktop it might be nessecary to specify the repository
35+
install.packages("phslookups", repos = "https://ppm-prod.publichealthscotland.org/phs-github/latest")
36+
```
37+
38+
To install the development version directly from GitHub.
2939

3040
``` r
3141
remotes::install_github("Public-Health-Scotland/phslookups")
3242
```
3343

34-
It is not yet available from the PHS Posit Package Manager, it will never be available on CRAN as it is intended to be an internal only package.
44+
Note that phslookups will never be available on CRAN as it is intended to be an internal-only package, and relies on lookup files on internal-only drives.
45+
46+
## Available lookups
47+
48+
- The Scottish Postcode Directory - `get_spd()`
49+
- HSCP Localities - `get_hscp_locality()`
50+
- SIMD lookups - `get_simd_datazone()` and `get_simd_postcode()`
3551

3652
## Example
3753

38-
Load the Scottish Postcode Directory
54+
Load the latest available version of the full Scottish Postcode Directory.
3955

40-
```{r example}
56+
```{r spd_latest_full}
4157
library(phslookups)
4258
4359
spd <- get_spd()
60+
head(spd)
61+
```
62+
63+
Get a specific version of a file, great if you want to 'lock' your code to a specific version too.
64+
65+
```{r version_examples}
66+
library(phslookups)
67+
68+
spd_23 <- get_spd(version = "2023_2")
69+
localities_mar_24 <- get_hscp_locality(version = "20240308")
70+
simd_dz_2016 <- get_simd_datazone(simd_version = "2016")
71+
simd_pc_2016_2012 <- get_simd_postcode(postcode_version = "2016_1", simd_version = "2012")
72+
```
73+
74+
Select only the necessary columns to reduce memory use and improve speed.
75+
76+
```{r col_select_examples}
77+
library(phslookups)
78+
library(dplyr)
79+
80+
postcode_coords <- get_spd(col_select = c("pc7", "latitude", "longitude"))
81+
dz_locality_lookup <- get_hscp_locality(col_select = c("datazone2011", "hscp_locality"))
82+
dz_simd2016_quintiles <- get_simd_datazone(
83+
simd_version = "2016",
84+
col_select = c("DataZone2011", contains("quintile"))
85+
)
4486
```

README.md

Lines changed: 87 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,104 @@ and use lookups which have been provided for analysis.
1515

1616
## Installation
1717

18-
You can install the latest version of phslookups from
19-
[GitHub](https://github.com) with:
18+
If you are internal to PHS, you can install the latest version of
19+
phslookups from the internal Posit Package Manager.
20+
21+
``` r
22+
# On the Posit Workbench
23+
install.packages("phslookups")
24+
25+
# On RStudio Desktop it might be nessecary to specify the repository
26+
install.packages("phslookups", repos = "https://ppm-prod.publichealthscotland.org/phs-github/latest")
27+
```
28+
29+
To install the development version directly from GitHub.
2030

2131
``` r
2232
remotes::install_github("Public-Health-Scotland/phslookups")
2333
```
2434

25-
It is not yet available from the PHS Posit Package Manager, it will
26-
never be available on CRAN as it is intended to be an internal only
27-
package.
35+
Note that phslookups will never be available on CRAN as it is intended
36+
to be an internal-only package, and relies on lookup files on
37+
internal-only drives.
38+
39+
## Available lookups
40+
41+
- The Scottish Postcode Directory - `get_spd()`
42+
- HSCP Localities - `get_hscp_locality()`
43+
- SIMD lookups - `get_simd_datazone()` and `get_simd_postcode()`
2844

2945
## Example
3046

31-
Load the Scottish Postcode Directory
47+
Load the latest available version of the full Scottish Postcode
48+
Directory.
3249

3350
``` r
3451
library(phslookups)
3552

3653
spd <- get_spd()
37-
#> ℹ Using "Scottish_Postcode_Directory_2024_1.parquet".
54+
#> ℹ Using the latest available version:
55+
#> "Scottish_Postcode_Directory_2026_1".
56+
#> If you require an older version or for reproducibility purposes
57+
#> please specify the version argument accordingly.
58+
head(spd)
59+
#> # A tibble: 6 × 95
60+
#> pc7 pc8 split_char pc_district pc_sector date_of_introduction
61+
#> <chr> <chr> <chr> <chr> <chr> <date>
62+
#> 1 AB1 0AA AB1 0AA <NA> AB1 AB1 0 1980-01-01
63+
#> 2 AB1 0AB AB1 0AB <NA> AB1 AB1 0 1973-08-01
64+
#> 3 AB1 0AD AB1 0AD <NA> AB1 AB1 0 1973-08-01
65+
#> 4 AB1 0AE AB1 0AE <NA> AB1 AB1 0 1994-02-01
66+
#> 5 AB1 0AF AB1 0AF <NA> AB1 AB1 0 1990-12-01
67+
#> 6 AB1 0AG AB1 0AG <NA> AB1 AB1 0 1990-12-01
68+
#> # ℹ 89 more variables: date_of_deletion <date>, postcode_type <chr>,
69+
#> # pc_su_link <chr>, split_su_link <chr>, imputed <chr>, dpc <int>,
70+
#> # dpc_nr <int>, hhc <int>, grid_reference_easting <int>,
71+
#> # grid_reference_northing <int>, latitude <dbl>, longitude <dbl>,
72+
#> # split_indicator <chr>, ca2019 <chr>, ca2019name <chr>, ca2018 <chr>,
73+
#> # ca2011 <chr>, upc2024 <chr>, spr2021 <chr>, spc2021 <chr>, ew2022 <chr>,
74+
#> # hb2019 <chr>, hb2019name <chr>, hb2018 <chr>, hb2014 <chr>, hb2006 <chr>, …
75+
```
76+
77+
Get a specific version of a file, great if you want to ‘lock’ your code
78+
to a specific version too.
79+
80+
``` r
81+
library(phslookups)
82+
83+
spd_23 <- get_spd(version = "2023_2")
84+
localities_mar_24 <- get_hscp_locality(version = "20240308")
85+
simd_dz_2016 <- get_simd_datazone(simd_version = "2016")
86+
simd_pc_2016_2012 <- get_simd_postcode(postcode_version = "2016_1", simd_version = "2012")
87+
```
88+
89+
Select only the necessary columns to reduce memory use and improve
90+
speed.
91+
92+
``` r
93+
library(phslookups)
94+
library(dplyr)
95+
#>
96+
#> Attaching package: 'dplyr'
97+
#> The following objects are masked from 'package:stats':
98+
#>
99+
#> filter, lag
100+
#> The following objects are masked from 'package:base':
101+
#>
102+
#> intersect, setdiff, setequal, union
103+
104+
postcode_coords <- get_spd(col_select = c("pc7", "latitude", "longitude"))
105+
#> ℹ Using the latest available version:
106+
#> "Scottish_Postcode_Directory_2026_1".
107+
#> If you require an older version or for reproducibility purposes
108+
#> please specify the version argument accordingly.
109+
dz_locality_lookup <- get_hscp_locality(col_select = c("datazone2011", "hscp_locality"))
110+
#> ℹ Using the latest available version:
111+
#> "HSCP Localities_DZ11_Lookup_20240513".
112+
#> If you require an older version or for reproducibility purposes
113+
#> please specify the version argument accordingly.
114+
dz_simd2016_quintiles <- get_simd_datazone(
115+
simd_version = "2016",
116+
col_select = c("DataZone2011", contains("quintile"))
117+
)
38118
```

0 commit comments

Comments
 (0)