Personal R package for British Red Cross data science work.
To install from this repository:
devtools::install_github("matthewgthomas/brclib") # make sure you have the devtools library installed first
library(brclib)
%**%
: Multiply numbers only if at least one of them isn't zeroadd_risk_quantiles
: Add risk quantiles to a dataframe for the given columnas_pc
: Convert proportions to %sconvert_date
: Convert dates if they're in Excel (numeric) formatcreate_lookup_lsoa_lad_county
: Create lookup table for Lower Layer Super Output Areas to Local Authorities to Countiescreate_lookup_msoa_lad_county
: Create lookup table for Middle Layer Super Output Areas to Local Authorities to Countiesdownload_shp
: Download and load shapefiles from the webdownload_wales
: Download data from Stats Wales (https://statswales.gov.wales)get_brc_colours
: Get a list of British Red Cross colour hex codesget_nhs_colours
: Get a list of NHS colour hex codesget_LSOAs
: Get Lower Layer Super Output Areas and devolved nations' equivalents in a single spatial dataframeget_month_num
: Convert month name to the month's numberload_IMD
: Load latest Index of Multiple Deprivation data for whole UKload_postcodes
: Load BRC's bespoke postcode directory (note the function to create this file hasn't been implemented in the package yet)lookup_islands_postcodes
: Lookup coordinates for UK postcodes that aren't in the ONS postcode directory (tends to be Guernsey, Jersey and Isle of Man), scraping them from https://checkmypostcode.uk/ where necessarypostcode_regex
: Regular expression to match postcodes (allowing lowercase and unlimited spaces)process_CRVs
: Clean and process Community Reserve Volunteers dataread_excel_entirely
: Load all worksheets in an Excel file into a single dataframeround_up
: Round up to nearest specified numberround_up_nice
: Round up to nearest 'nice' numberThe package assumes that all relevant data are stored within sub-folders of a base data directory. To see the default data directory, run:
options("brclib.data_path")
To change this directory, run:
options("brclib.data_path" = "<PATH TO DATA FOLDER>")
The documentation for each function explains where it expects to find data. You can often set custom data directories in the parameters of individual functions.