Tools

The small utilities that keep everyday analysis quick, consistent and safe to share.

R package

VLabR

VLabR 0.0.0.9043 is a lightweight R package for everyday health-data work: tidy column names, file import, one-row summaries, dates, stable de-identified IDs, personal-name masking, and travel to Alberta hospitals. Name masking can use Python and spaCy when available, with a pure-R fallback for locked-down work computers. Requires R 4.4.0 or later.

View VLabR on GitHub →

Install

install.packages("remotes")
remotes::install_github("The-V-Lab/VLabR", upgrade = "never")

library(VLabR)
vlab_load_vlabr_packages()

Selected functions

FunctionWhat it does
Data cleaning and files
vlab_fix_colname()Clean column names: strip selected special characters and replace spaces.
vlab_quote_rm()Remove stray quotes from character and factor columns.
vlab_get_duplicates()Return duplicate rows by one or more keys.
vlab_check_unique()Check whether a column is unique.
vlab_data_type()Classify columns as continuous, categorical, date or other.
vlab_similarscore()Similarity score from 0 to 1 for strings or numbers, allowing common typos.
vlab_read_csv(), vlab_read_xlsx(), vlab_read_rds()Import one file, or every file of that type in a directory.
vlab_SRds(), vlab_LRds()Save an R object to RDS, and restore it.
Dates
vlab_todate(), vlab_todatetime()Convert common date and date-time inputs, including two-digit years.
vlab_today()Today's date in underscore and compact formats.
vlab_boost_data()Detect and convert date-like columns in a data frame.
vlab_withintime()1/0 flag for whether two date-times fall within a chosen interval.
vlab_second2format()Format seconds as HH:MM:SS, with hours past 24.
Summary tables
vlab_1_cat()One-row n (%) table for a categorical variable.
vlab_1_cont()One-line summary for a continuous variable.
vlab_cross_table()Two-variable cross table with counts and percentages.
vlab_count_unique_categories()Count unique non-missing categories.
vlab_compare_balance()Compare covariate balance between two data frames.
De-identification
vlab_SID_creator()Stable de-identified study ID from name, date of birth and gender.
vlab_setup_name_masking()Prepare spaCy when available, or the pure-R fallback.
vlab_mask_person_names()Replace detected personal names in free text. The older name mask_person_names() still works.
vlab_detect_person_names(), vlab_name_flag()Audit detected names, or return a 1/0 flag for each text value.
vlab_mask_person_names2(), vlab_name_flag2()Mask or flag only names that match row-aligned known-name columns.
vlab_mask_PHN(), vlab_mask_PHN_flag()Mask a nine-digit Personal Health Number near a PHN label, or flag that one is present.
vlab_mask()Mask vector values from the front or back.
Alberta hospitals and travel
alberta_hospitalsOffline list of 112 Alberta facilities, with addresses and coordinates. Checked 12 October 2026; 94 have a regular 24-hour emergency department.
vlab_nearest_hospitals()Add the three nearest hospitals by road distance, plus routes to Foothills Medical Centre and University of Alberta Hospital.
vlab_travel()Experimental: road distance and time for origin–destination pairs via OSRM.
vlab_google_travel()In development: the same idea with the Google Routes API. Not for production use yet.
Other reference setsMunicipalities, the broader health-facility list, schools and Health Canada drug products.
Practice notes

Python Lab

A running set of beginner Python exercises — variables, type casting, input, conditionals, string methods, loops and functions — written as small, printable programs.