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
%**%: Multiply numbers only if at least one of them isn't zero
add_risk_quantiles: Add risk quantiles to a dataframe for the given column
as_pc: Convert proportions to %s
convert_date: Convert dates if they're in Excel (numeric) format
create_lookup_lsoa_lad_county: Create lookup table for Lower Layer Super Output Areas to Local Authorities to Counties
create_lookup_msoa_lad_county: Create lookup table for Middle Layer Super Output Areas to Local Authorities to Counties
download_shp: Download and load shapefiles from the web
download_wales: Download data from Stats Wales (https://statswales.gov.wales)
get_brc_colours: Get a list of British Red Cross colour hex codes
get_nhs_colours: Get a list of NHS colour hex codes
get_LSOAs: Get Lower Layer Super Output Areas and devolved nations' equivalents in a single spatial dataframe
get_month_num: Convert month name to the month's number
load_IMD: Load latest Index of Multiple Deprivation data for whole UK
load_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 necessary
postcode_regex: Regular expression to match postcodes (allowing lowercase and unlimited spaces)
process_CRVs: Clean and process Community Reserve Volunteers data
read_excel_entirely: Load all worksheets in an Excel file into a single dataframe
round_up: Round up to nearest specified number
round_up_nice: Round up to nearest 'nice' number
The package assumes that all relevant data are stored within sub-folders of a base data directory. To see the default data directory, run:
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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.