Created
January 3, 2014 04:41
-
-
Save dfalster/8232865 to your computer and use it in GitHub Desktop.
Function to convert vector of binomial species names into a vector of 6 letter abbreviations, taking first 3 letters from first and second names. Example: spp_code(c("Quassia baileyana","Rhodomyrtus trineura","Rockinghamia angustifolia"))
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
spp_code <- function(species_names){ | |
sapply(strsplit(species_names, " "), function(x) tolower(paste0(substr(x[1], 1,3), substr(x[2], 1,3)))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment