Created
December 19, 2017 12:07
-
-
Save zdealveindy/e2ccfeba9fe1cd33ac4946afeaeaa68b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create.abbrev2 <- function (names, sep = '') | |
{ | |
Gene <- names %>% # note Gene with uppercase G to show that beginning has uppercase lettter | |
str_split (' ') %>% | |
sapply (FUN = function (x) x[1]) %>% | |
str_sub (start = 1, end = 4) | |
spec <- names %>% # spec with lowercase s | |
str_split (' ') %>% | |
sapply (FUN = function (x) x[2]) %>% | |
str_sub (start = 1, end = 4) | |
Spec <- paste ( # Spec with uppercase S - now the abbreviation has first letter uppercase | |
spec %>% str_sub (start = 1, end = 1) %>% str_to_upper (), | |
spec %>% str_sub (start = 2, end = 4), | |
sep = '') | |
paste (Gene, Spec, sep = sep) # paste Gene and Spec together with optional separator | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment