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.0 ──
#> ✓ ggplot2 3.3.3     ✓ purrr   0.3.4
#> ✓ tibble  3.1.0     ✓ dplyr   1.0.4
#> ✓ tidyr   1.1.3     ✓ stringr 1.4.0
#> ✓ readr   1.4.0     ✓ forcats 0.5.0
#> ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
#> x dplyr::filter() masks stats::filter()
#> x 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)