Learn R Programming

chromConverter (version 0.12.0)

subset.chrom_list: Select chromatograms by their metadata

Description

Retains the chromatograms of a chrom_list whose metadata meet the specified condition, such as sample_name == "blank" or run_datetime > as.POSIXct("2024-01-01", tz = "UTC"). The condition can refer to any field extract_metadata reports, such as sample_name or method, as well as the chromatogram's name in the list.

Usage

# S3 method for chrom_list
subset(x, subset, ...)

Value

A chrom_list containing the selected chromatograms.

Arguments

x

A chrom_list object.

subset

An expression giving a single TRUE or FALSE for each chromatogram.

...

Ignored.

Details

Numeric fields such as time_range and sample_injection_volume compare as numbers wherever the file's value parses as one, and a field with several values can be indexed (e.g. time_range[2]). A field a chromatogram does not carry is NA, and a chromatogram for which subset is NA is dropped, as in subset() for data frames. Where an element holds several chromatograms, such as the traces read_agilent_d returns for each .D directory, it is kept or dropped as a whole, and subset sees the fields its chromatograms agree on, ignoring those that leave a field empty; a field they disagree on is NA.

See Also

extract_metadata

Examples

Run this code
path <- system.file("extdata", "benzoxazinoid_standards",
                    package = "chromConverter")
chroms <- read_chroms(path, format_in = "chemstation_ch", pattern = "dad1A",
                      parser = "chromconverter", progress_bar = FALSE)
subset(chroms, sample_name != "MEOH")
subset(chroms, run_datetime < as.POSIXct("2023-06-21", tz = "UTC"))

Run the code above in your browser using DataLab