Combines a chemical formula with a specified adduct, and returns the resultant summed formula. This function can handle addition or subtraction of elements from the main formula based on the adduct.
sum_formula(formula = "C9H11NO2", adduct = "M-H2O+H")
A character string of the resulting chemical formula after combining the base formula with the adduct. If an error occurs or the summation results in negative counts for any element, it returns `NA`.
sum_formula(formula = "C9H11NO2", adduct = "M+H")
#> [1] "C9H12NO2"
sum_formula(formula = "C9H11NO2", adduct = "M+")
#> [1] "C9H11NO2"
sum_formula(formula = "C9H11NO2", adduct = "M+CH3COOH")
#> [1] "C11H15NO4"
sum_formula(formula = "C9H11", adduct = "M-H20")
#> [1] NA