Vectorised function to calculate HLA mismatch levels where the HLA A, B and DR mismatch is recorded as a string rather than as separate numeric values, e.g. "1:0:1" or "101". The function calculates the mismatch level as used in the UK national deceased donor kidney matching scheme. By default, the function assumes a single separator character is used between each of the three numbers in the mismatch; if not, set the sep parameter to FALSE. This function needs the stringr package to be installed.
hla_mm_level_str(mm, sep = TRUE)
numeric vector of HLA mismatch levels
The HLA mismatch level is derived from UK kidney matching policies which can be found on the NHS Blood & Transplant ODT website at www.odt.nhs.uk
# using string of HLA mismatches with colons
hla_mm_level_str("1:1:0")
#> [1] 2
# using string of HLA mismatches without separator
hla_mm_level_str("211", sep = FALSE)
#> [1] 3