### Install phslookups from Posit Workbench Source: https://github.com/public-health-scotland/phslookups/blob/main/README.md Install the phslookups package from the internal Posit Package Manager on the Posit Workbench. ```r install.packages("phslookups") ``` -------------------------------- ### Install phslookups from GitHub Source: https://github.com/public-health-scotland/phslookups/blob/main/README.md Install the development version of the phslookups package directly from GitHub using the remotes package. ```r remotes::install_github("Public-Health-Scotland/phslookups") ``` -------------------------------- ### Install phslookups from RStudio Desktop Source: https://github.com/public-health-scotland/phslookups/blob/main/README.md Install the phslookups package on RStudio Desktop, potentially requiring explicit repository specification. ```r install.packages("phslookups", repos = "https://ppm-prod.publichealthscotland.org/phs-github/latest") ``` -------------------------------- ### Get Lookups Directory Path Source: https://github.com/public-health-scotland/phslookups/blob/main/tests/testthat/_snaps/windows/get_lookups_dir.md Call the get_lookups_dir() function to retrieve the expected directory path for lookups on Windows systems. ```R get_lookups_dir() ``` -------------------------------- ### Select specific columns for efficiency Source: https://github.com/public-health-scotland/phslookups/blob/main/README.md Retrieve only necessary columns from lookup data using the col_select argument to reduce memory usage and improve performance. This example demonstrates selecting columns for postcode coordinates and datazone-locality mapping. ```r library(phslookups) library(dplyr) #> #> Attaching package: 'dplyr' #> The following objects are masked from 'package:stats': #> #> filter, lag #> The following objects are masked from 'package:base': #> #> intersect, setdiff, setequal, union postcode_coords <- get_spd(col_select = c("pc7", "latitude", "longitude")) #> ℹ Using the latest available version: #> "Scottish_Postcode_Directory_2026_1". #> If you require an older version or for reproducibility purposes #> please specify the version argument accordingly. dz_locality_lookup <- get_hscp_locality(col_select = c("datazone2011", "hscp_locality")) #> ℹ Using the latest available version: #> "HSCP Localities_DZ11_Lookup_20240513". #> If you require an older version or for reproducibility purposes #> please specify the version argument accordingly. dz_simd2016_quintiles <- get_simd_datazone( simd_version = "2016", col_select = c("DataZone2011", contains("quintile")) ) ``` -------------------------------- ### Retrieve specific versions of lookup data Source: https://github.com/public-health-scotland/phslookups/blob/main/README.md Get specific versions of the Scottish Postcode Directory, HSCP Localities, and SIMD data using the version argument. This is useful for reproducibility. ```r library(phslookups) spd_23 <- get_spd(version = "2023_2") localities_mar_24 <- get_hscp_locality(version = "20240308") simd_dz_2016 <- get_simd_datazone(simd_version = "2016") simd_pc_2016_2012 <- get_simd_postcode(postcode_version = "2016_1", simd_version = "2012") ``` -------------------------------- ### Load and view Scottish Postcode Directory Source: https://github.com/public-health-scotland/phslookups/blob/main/README.md Load the phslookups library and retrieve the latest version of the Scottish Postcode Directory, then display the first few rows. ```r library(phslookups) spd <- get_spd() #> ℹ Using the latest available version: #> "Scottish_Postcode_Directory_2026_1". #> If you require an older version or for reproducibility purposes #> please specify the version argument accordingly. head(spd) #> # A tibble: 6 × 95 #> pc7 pc8 split_char pc_district pc_sector date_of_introduction #> #> 1 AB1 0AA AB1 0AA AB1 AB1 0 1980-01-01 #> 2 AB1 0AB AB1 0AB AB1 AB1 0 1973-08-01 #> 3 AB1 0AD AB1 0AD AB1 AB1 0 1973-08-01 #> 4 AB1 0AE AB1 0AE AB1 AB1 0 1994-02-01 #> 5 AB1 0AF AB1 0AF AB1 AB1 0 1990-12-01 #> 6 AB1 0AG AB1 0AG AB1 AB1 0 1990-12-01 #> # ℹ 89 more variables: date_of_deletion , postcode_type , #> # pc_su_link , split_su_link , imputed , dpc , #> # dpc_nr , hhc , grid_reference_easting , #> # grid_reference_northing , latitude , longitude , #> # split_indicator , ca2019 , ca2019name , ca2018 , #> # ca2011 , upc2024 , spr2021 , spc2021 , ew2022 , #> # hb2019 , hb2019name , hb2018 , hb2014 , hb2006 , … ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.