UFSA_formula_vector_generator: Molecular Formula Vector Generator

View source: R/UFSA_formula_vector_generator.R

UFSA_formula_vector_generatorR Documentation

Molecular Formula Vector Generator

Description

This function convert a molecular formulas into a numerical vector

Usage

UFSA_formula_vector_generator(molecular_formula, Elements, LElements = length(Elements),
allowedRedundantElements = FALSE)

Arguments

molecular_formula

molecular formula

Elements

a string vector of elements. This value must be driven from the 'element_sorter' function.

LElements

number of elements. To speed up loop calculations, consider calculating the number of elements outside of the loop.

allowedRedundantElements

'TRUE' should be used to deconvolute molecular formulas with redundant elements (e.g. CO2CH3O), and 'FALSE' should be used to skip such complex molecular formulas.(default value)

Value

a numerical vector for the molecular formula. This function returns a vector of -Inf values when the molecular formula has elements not listed in the 'Elements' string vector.

Examples

molecular_formula <- "C12H2Br5Cl3O"
Elements <- UFSA_element_sorter()
mol_vec <- UFSA_formula_vector_generator(molecular_formula, Elements)
##
regenerated_molecular_formula <- UFSA_hill_molecular_formula_printer(Elements, mol_vec)

IDSL.FSA documentation built on July 9, 2023, 6:45 p.m.