Skip to contents

Get the sampling interval of a chromatogram: the median gap between consecutive retention times.

Usage

get_time_resolution(x, idx = 1, digits = 6, unit = NULL)

Arguments

x

A chromatogram, a list of chromatograms, or a peak_table object.

idx

Index of the chromatogram from which to derive the interval, if x is a list or peak_table. Defaults to 1.

digits

Number of significant digits to round to. Defaults to 6, because a regular time axis carries floating-point noise in the last digits of diff.

unit

Unit for the returned interval: "min", "s" or "ms". Defaults to NULL, giving the interval in the units of the chromatogram's own time axis, which is what preprocess's dim1 expects. Supply "min" to pair with the time_resolution arguments of plot_chroms and reshape_chroms, which are in minutes, regardless of the units of x. The units of x are read from its time_unit attribute, falling back to minutes when it is absent, as plot_chroms does.

Value

A length-one numeric giving the time between consecutive timepoints, in unit if supplied and otherwise in the units of the chromatogram's time axis.

See also

Examples

data(Sa_warp)
get_time_resolution(Sa_warp)
#> [1] 0.02