Skip to contents

Condense the number of samples of a dataframe using time-weighted averaging.

Usage

downsample_data(
  data,
  sample_column = NULL,
  sample_rate = NULL,
  downsample_rate = NULL,
  downsample_time = NULL,
  verbose = TRUE
)

Arguments

data

A dataframe.

sample_column

An optional character scalar indicating the name of the time or sample data column. Must match exactly.

sample_rate

An optional numeric scalar for the sample rate in Hz.

downsample_rate

An optional numeric scalar indicating the desired output sample rate (in Hz) to convert the dataframe.

downsample_time

An optional numeric scalar indicating the desired sample time (in seconds) to convert the dataframe.

verbose

A logical. TRUE (the default) will return warnings and messages which can be used for data error checking. FALSE will silence these messages. Errors will always be returned.

Value

A tibble of class mNIRS.data with metadata available with attributes().

Details

sample_column and sample_rate will be taken from metadata for an mNIRS dataframe, if not defined explicitly.

If not present in metadata, sample_column must be defined explicitly. sample_rate will be estimated based on the mean difference between values in the sample_column. If sample_column contains integer sample numbers, then sample_rate will be incorrectly estimated to be 1 Hz, and should be defined explicitly.

TODO include upsample interpolation?