Learn R Programming

heartbeatr (version 1.0.0)

pulse_choose_keep: (STEP 6) Choose the best heart beat frequency estimate from among two estimates derived from raw and smoothed data

Description

  • step 1 -- pulse_read()

  • step 2 -- pulse_split()

  • step 3 -- pulse_optimize()

  • step 4 -- pulse_heart()

  • step 5 -- pulse_doublecheck()

  • -->> step 6 -- pulse_choose_keep() <<--

When running pulse_optimize() or PULSE() with raw_v_smoothed = TRUE, two estimates are generated for each data point, and pulse_choose_keep is used to automatically select the best one (based on N and SD levels set by the user). NOTE: if supplied with input data generated using raw_v_smoothed = FALSE, pulse_choose_keep outputs the same data, unchanged.

Usage

pulse_choose_keep(heart_rates, lim_n = 3, lim_sd = 0.75)

Value

A tibble with the same structure as the input, but now with only one estimate for each combination of id and time (the one that was deemed better).

Arguments

heart_rates

the output from pulse_heart()

lim_n

numeric, defaults to 3; minimum number of peaks detected in each time window for it to be considered a "keep".

lim_sd

numeric, defaults to 0.75; maximum value for the sd of the time intervals between each peak detected for it to be considered a "keep"

See Also

  • pulse_read(), pulse_split(), pulse_optimize(), pulse_heart() and pulse_doublecheck() are the other functions needed for the complete PULSE processing workflow

  • PULSE() is a wrapper function that executes all the steps needed to process PULSE data at once

Examples

Run this code
## Begin prepare data ----
pulse_data_sub <- pulse_data
pulse_data_sub$data <- pulse_data_sub$data[,1:2]
pulse_data_split <- pulse_split(pulse_data_sub)
pulse_data_split <- pulse_optimize(pulse_data_split, multi = pulse_data$multi)
heart_rates <- pulse_heart(pulse_data_split)
## End prepare data ----

nrow(heart_rates)
heart_rates <- pulse_choose_keep(heart_rates)
nrow(heart_rates) # halved

Run the code above in your browser using DataLab