#' Convert two-letter species codes used in Inventory Data dataset to full common names
#'
#' @param x the InventoryData dataframe
#' @return a vector of transformed values
#'
SpeciesNames <- function(x){
CommonNames <- list("SA" = "Speckled Alder",
"BF" = "Balsam Fir",
"RM" = "Red Maple",
"RS" = "Red Spruce",
"BH" = "Beaked Hazelnut",
"AB" = "American Beech",
"STM" = "Striped Maple",
"YB" = "Yellow Birch",
"EH" = "Eastern Hemlock",
"SM" = "Sugar Maple",
"MM" = "Mountain Maple",
"WP" = "White Pine",
"PB" = "Paper Birch",
"HW" = "Deciduous",
"SB" = "Black Birch",
"BB" = "Blue Beech",
"SW" = "Coniferous",
"WA" = "White Ash",
"AE" = "American Elm",
"SIM" = "Silver Maple",
"FC" = "Fire Cherry",
"RO" = "Red Oak",
"BC" = "Black Cherry",
"ET" = "Eastern Tamarack",
"BS" = "Black Spruce",
"WC" = "White Cedar",
"QA" = "Quaking Aspen")
x <- x %>%
mutate(CommonNames = x$Species)
for(i in 1:length(CommonNames)){
x$CommonNames <- gsub(paste0("\\b", names(CommonNames)[i], "\\b"), CommonNames[[i]], x$CommonNames)
}
x$CommonNames
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.