Skip to contents

This function parses a tab-delimited string containing chemical data and converts it into a data frame. The string contains columns such as "Input m/z", "Matched m/z", "Delta", "Name", "Systematic name", "Formula", "Ion", "Category", "Main class", and "Sub class".

Usage

parse_mw_output(result)

Arguments

result

A character string, typically the output of a mw_request() function that returns a tab-delimited string.

Value

A data frame where each row represents a set of chemical data parsed from the input string. The columns include "Input m/z", "Matched m/z", "Delta", "Name", "Systematic name", "Formula", "Ion", "Category", "Main class", and "Sub class".

Examples

result <- paste0(
    "Input m/z\tMatched m/z\tDelta\tName\tSystematic name\tFormula\t",
    "Ion\tCategory\tMain class\tSub class\n",
    "180.063\t180.0634\t.0004\t1,3,4,5,6-Pentahydroxyhexan-2-One\t",
    "1,3,4,5,6-pentahydroxyhexan-2-one\tC6H12O6\tNeutral\tOrganic oxygen ",
    "compounds\tOrganooxygen compounds\tCarbohydrates and carbohydrate ",
    "conjugates"
)
parsed_data <- parse_mw_output(result)
print(parsed_data)
#> # A tibble: 1 × 10
#>   `Input m/z` `Matched m/z` Delta Name  `Systematic name` Formula Ion   Category
#>         <dbl>         <dbl> <dbl> <chr> <chr>             <chr>   <chr> <chr>   
#> 1        180.          180.  4e-4 1,3,… 1,3,4,5,6-pentah… C6H12O6 Neut… Organic…
#> # ℹ 2 more variables: `Main class` <chr>, `Sub class` <chr>