From f372f4922853210d1e400b44b60aaaa593cce17a Mon Sep 17 00:00:00 2001 From: Pranav Anbarasu Date: Tue, 12 Mar 2024 19:24:51 +0000 Subject: [PATCH] Add HeartRateVariability to list of variables to restrict range of values for --- scripts/process-data/healthkitv2samples.R | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/scripts/process-data/healthkitv2samples.R b/scripts/process-data/healthkitv2samples.R index 851ac84..6ceac85 100644 --- a/scripts/process-data/healthkitv2samples.R +++ b/scripts/process-data/healthkitv2samples.R @@ -39,13 +39,16 @@ df <- colnames(df) <- tolower(colnames(df)) # Get QA/QC ranges for variables and exclude values outside the ranges -criteria <- list(selected_vars$Variable=="AverageHeartRate" & selected_vars$Export=="fitbitactivitylogs", - selected_vars$Variable=="BreathingRate" & selected_vars$Export=="fitbitdailydata", - selected_vars$Variable=="SpO2_Avg" & selected_vars$Export=="fitbitdailydata") - -bounds <- data.frame(Variable = c("HeartRate", "RespiratoryRate", "OxygenSaturation"), - Lower_Bound = sapply(criteria, function(x) selected_vars$Lower_Bound[x]), - Upper_Bound = sapply(criteria, function(x) selected_vars$Upper_Bound[x])) +criteria <- + list(selected_vars$Variable=="AverageHeartRate" & selected_vars$Export=="fitbitactivitylogs", + selected_vars$Variable=="BreathingRate" & selected_vars$Export=="fitbitdailydata", + selected_vars$Variable=="SpO2_Avg" & selected_vars$Export=="fitbitdailydata", + selected_vars$Variable=="Hrv_DailyRmssd" & selected_vars$Export=="fitbitdailydata") + +bounds <- + data.frame(Variable = c("HeartRate", "RespiratoryRate", "OxygenSaturation", "HeartRateVariability"), + Lower_Bound = sapply(criteria, function(x) selected_vars$Lower_Bound[x]), + Upper_Bound = sapply(criteria, function(x) selected_vars$Upper_Bound[x])) bounds$Lower_Bound[bounds$Variable=="OxygenSaturation"] <- bounds$Lower_Bound[bounds$Variable=="OxygenSaturation"]/100 bounds$Upper_Bound[bounds$Variable=="OxygenSaturation"] <- bounds$Upper_Bound[bounds$Variable=="OxygenSaturation"]/100