There are also a lot of useful tools in metID.

library(metID)
#> metID,
#> More information can be found at https://jaspershen.github.io/metID/
#> If you use metID in you publication, please cite this publication:
#> Metabolic reaction network-based recursive metabolite annotation for untargeted metabolomics.
#> Authors: Xiaotao Shen (shenxt1990@163.com)
#> Maintainer: Xiaotao Shen.
library(tidyverse)
#> ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
#>  ggplot2 3.3.6           purrr   0.3.4     
#>  tibble  3.1.7           dplyr   1.0.9     
#>  tidyr   1.2.0           stringr 1.4.0     
#>  readr   2.1.2           forcats 0.5.1.9000
#> ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
#>  dplyr::filter() masks stats::filter()
#>  dplyr::lag()    masks stats::lag()

Read MS2 data

Read msp format file using readMGF

result <- readMGF(file)

Read mzXML format file using readMZXML

result <- readMZXML(file, threads = 3)

Read MGF format file using readMGF

result <- readMGF(file)
metID::metID()
#> `metID()` is deprecated, please use `metID_logo()`.                _    _____  ___ 
#>  _ __ ___   ___| |_  \_   \/   \
#> | '_ ` _ \ / _ \ __|  / /\/ /\ /
#> | | | | | |  __/ |_/\/ /_/ /_// 
#> |_| |_| |_|\___|\__\____/___,'  
#>