Learn R Programming

IDSL.FSA (version 1.2)

UFSA_formula_vector_generator: 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)

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.

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)

Examples

Run this code
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)

Run the code above in your browser using DataLab