SymboltoElementName: Convert element symbol to full element name

Description Usage Arguments Value Author(s) Examples

Description

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.

Usage

1

Arguments

els

String or vector of values to be converted.

Value

Returns of vector of same length as input with translated values.

Author(s)

Greg Ziegler

Examples

 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
  }

gziegler/ionomicsUtils documentation built on June 20, 2019, 8:04 p.m.