Breaks down a chemical formula into its individual elements and counts, returning the results as a data frame.
Character string representing the chemical formula to be parsed.
A data frame with two columns: 'Element' and 'Count', representing each element and its count in the given formula.
Parse a Chemical Formula into its Constituent Elements and Counts
This function breaks down a chemical formula into its individual elements and their respective counts. If no count is specified for an element, it defaults to 1. The result is presented as a data frame with columns for elements and counts.
parse_chemical_formula("H2O") # Returns a data frame with H:2 and O:1 #> Element Count #> 1 H 2 #> 2 O 1 parse_chemical_formula("C6H12O6") # Returns a data frame with C:6, H:12, and O:6 #> Element Count #> 1 C 6 #> 2 H 12 #> 3 O 6 parse_chemical_formula("Fe2O3") # Returns a data frame with Fe:2 and O:3 #> Element Count #> 1 Fe 2 #> 2 O 3