Description Usage Arguments Value Author(s) Examples
Takes an element symbol or symbol isotope transformation type (e.g. Na23_normConc) and converts to element name (e.g. Sodium) If an element isn't found in the lookup table, the value is returned unchanged with a warning. Translation currently only includes commonly used ionomic elements.
1 | SymboltoElementName(els)
|
els |
String or vector of values to be converted. |
Returns of vector of same length as input with translated values.
Greg Ziegler
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | SymboltoElementName(c("Na23_normConc","Na23_corrConc","Na23","S","weight","otherID"))
## The function is currently defined as
function (els)
{
els <- sub("_\\w+", "", els)
els <- sub("\\d+", "", els)
elTable <- data.frame(Element = c("Boron", "Sodium", "Magnesium",
"Aluminum", "Phosphorus", "Sulfur", "Potassium", "Calcium",
"Manganese", "Iron", "Cobalt", "Nickel", "Copper", "Zinc",
"Arsenic", "Selenium", "Rubidium", "Strontium", "Molybdenum",
"Cadmium", "Indium", "Yttrium", "Lead"), Symbol = c("B",
"Na", "Mg", "Al", "P", "S", "K", "Ca", "Mn", "Fe", "Co",
"Ni", "Cu", "Zn", "As", "Se", "Rb", "Sr", "Mo", "Cd",
"In", "Y", "Pb"), stringsAsFactors = FALSE)
out <- elTable[match(els, elTable$Symbol), "Element"]
if (length(which(is.na(out))) > length(which(is.na(els)))) {
warning("Some values from input not found in symbol lookup table. Original value returned")
}
out[which(is.na(out))] <- els[which(is.na(out))]
out
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.