Description Usage Arguments Value Examples
Reduce a long HLA allele string (i.e. "01:02:01:03g") down to fewer fields, default being 2 fields. NMDP codes are preserved, trailing "G" are removed, NA or empty string input generates NA output, anything else is output as-is, cast as string. No input or output validation is done on the data to ensure it meets expected HLA allele string formats.
1 | shorten_allele(allele, fields = 2)
|
allele |
String, including ":" but not initial "A*", so for example "01:02:01:03" |
fields |
Number of fields to keep, default = 2 which would return "01:02" |
character vector with shortened fields
1 2 3 4 5 | dat <- data.frame(HLA_A1 = c("01:02:01:03", "03:ADJRE", "01:02:01:01G"), stringsAsFactors = FALSE)
shorten_allele(dat$HLA_A1)
shorten_allele(dat$HLA_A1, fields = 3)
dat2 <- data.frame(HLA_A1 = c("01:02:01:03", "03:ADJRE", NA, "some_random_string", 2, ""), stringsAsFactors = FALSE)
shorten_allele(dat2$HLA_A1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.