The custom mass set will be available in subsequent calls of get_mass()
.
You may specify masses of selected elements only. In this case, however,
calculating the mass of a formula that contains an element whose mass was not
specified will return NA
.
new_mass_set(masses, inherits_from = NULL)
masses | Named numeric vector of the form |
---|---|
inherits_from | Mass set from which masses should be inherited if they
are not specified in |
A named numeric vector containing supplied and inherited element masses.
get_mass()
for calculating molecular masses, atomic_masses
for
predefined mass sets "average"
and "monoisotopic"
my_masses <- new_mass_set(c(H = 10, C = 100, O = 1)) molecular_formula("C6 H8 O5") %>% get_mass(my_masses)#> [1] 685# returns NA since my_masses does not specify the mass of sulfur molecular_formula("H2 S O4") %>% get_mass(my_masses)#> [1] NA# inherit masses from another mass set to provide default values my_masses_complete <- new_mass_set( c(H = 10, C = 100, O = 1), inherits_from = "average" ) molecular_formula("H2 S O4") %>% get_mass(my_masses_complete)#> [1] 56.06