formulastring.to.list {RMassBank} | R Documentation |
Converts molecular formulas from string to list representation or vice versa.
list.to.formula(flist) formulastring.to.list(formula)
formula |
A molecular formula in string format, e.g. |
flist |
A molecular formula in list format, e.g. |
The function doesn't care about whether your formula makes sense. However,
"C3.5O4"
will give list("C" = 3, "O" = 4)
because regular
expressions are used for matching (however, list("C" = 3.5, "O" = 4)
gives "C3.5O4"
.) Duplicate elements cause problems; only "strict"
molecular formulas ("CH4O", but not "CH3OH") work correctly.
list.to.formula
returns a string representation of the
formula; formulastring.to.list
returns the list representation.
Michael Stravs
add.formula
, order.formula
,
is.valid.formula
# list.to.formula(list("C" = 4, "H" = 12)) # This is also OK and useful to calculate e.g. adducts or losses. list.to.formula(list("C" = 4, "H" = -1)) formulastring.to.list(list.to.formula(formulastring.to.list("CHIBr")))