## Begin prepare data ----
paths <- pulse_example()
heart_rates <- PULSE(
paths,
discard_channels = c(paste0("c0", c(1:7, 9)), "c10"),
show_progress = FALSE
)
## End prepare data ----
# Summarise heartbeat estimates (1 data point every 5 mins)
nrow(heart_rates) # == 13
summarised_5mins <- pulse_summarise(heart_rates, span_mins = 5)
nrow(summarised_5mins) # == 3
summarised_5mins
# using a custom function
pulse_summarise(heart_rates, span_mins = 5, FUN = function(x) quantile(x, 0.2))
# normalized data is supported automatically
pulse_summarise(pulse_normalize(heart_rates))
# Note that visualizing the output from 'plot_summarise()' with
# 'pulse_plot()' may result in many warnings
pulse_plot(summarised_5mins)
"> There were 44 warnings (use warnings() to see them)"
# That happens when the value chosen for 'span_mins' is such
# that the output from 'plot_summarise()' doesn't contain
# enough data points for the smoothing curve to be computed
# Alternatively, do one of the following:
# reduce 'span_mins' to still get enough data points
pulse_plot(pulse_summarise(heart_rates, span_mins = 2, min_data_points = 0))
# or disable the smoothing curve
pulse_plot(summarised_5mins, smooth = FALSE)
Run the code above in your browser using DataLab