Skip to contents

countElements parses strings representing a chemical formula into a named vector of element counts.

Usage

countElements(x)

Arguments

x

character() representing a chemical formula.

Value

list of integer with the element counts (names being elements).

See also

Author

Michael Witting and Sebastian Gibb

Examples

countElements(c("C6H12O6", "C11H12N2O2"))
#> $C6H12O6
#>  C  H  O 
#>  6 12  6 
#> 
#> $C11H12N2O2
#>  C  H  N  O 
#> 11 12  2  2 
#>