add.formula {RMassBank} | R Documentation

## Calculations on molecular formulas

### Description

Add, subtract, and multiply molecular formulas.

### Usage

    add.formula(f1, f2, as.formula = TRUE, as.list = FALSE)
    multiply.formula(f1, n, as.formula = TRUE, as.list = FALSE)

### Arguments

`f1, f2` | Molecular formulas (in list form or in text form) to calculate with.
`as.formula` | Return the result as a text formula (e.g. `"C6H12O6"`). This is the default
`as.list` | Return the result in list format (e.g. `list(C=6, H=12, O=6)`).
`n` | Multiplier (positive or negative, integer or non-integer.)

### Details

Note that the results are not checked for plausibility at any stage, nor reordered.

### Value

The resulting formula, as specified above.

### Author(s)

Michael Stravs

### See Also

`formulastring.to.list`, `is.valid.formula`, `order.formula`

### Examples

    ##

    add.formula("C6H12O6", "C3H3")
    add.formula("C6H12O6", "C-3H-3")
    add.formula("C6H12O6", multiply.formula("C3H3", -1))

[Package RMassBank version 2.15.3 Index]