knitr::opts_chunk$set(echo = TRUE, message=FALSE, warning=FALSE, echo = FALSE) library(magrittr) library(ggplot2) library(patchwork) df1_means <- params$results_summary_means df1_medians <- params$results_summary_medians df2 <- params$results_by_day axis_mvpa_graph <- ifelse(params$axis_mvpa == "vertical axis", "axis1", ifelse(params$axis_mvpa == "vector magnitude", "vm", "na")) height_factor1 = nlevels(as.factor(params$df_with_computed_metrics$date)) * 0.8 height_factor1 <- ifelse(height_factor1 <= 6, nlevels(as.factor(params$df_with_computed_metrics$date)) * 0.9, height_factor1) height_factor2 = params$results_summary_means$valid_days * 0.75 height_factor2 <- ifelse(height_factor2 <= 6, nlevels(as.factor(params$df_with_computed_metrics$date)) * 0.9, height_factor2) height_factor3 = nlevels(as.factor(params$df_with_computed_metrics$date)) * 1.5 options("scipen"=100, "digits"=4)
Patient: r params$patient_surname
r params$patient_name
| Date: r Sys.Date()
| Assessor: r params$assessor_surname
r params$assessor_name
Age: r params$age
yr | Sex: r params$sex
| Weight: r params$weight
kg | Measurement period: r format(params$start_date, "%Y-%m-%d %H:%M:%S")
to r format(params$end_date, "%Y-%m-%d %H:%M:%S")
| Estimated Basal Metabolic Rate (BMR): r format(round(params$bmr_kcal_d, 2), nsmall = 2)
kcal/day (Estimation based on Henry equations [2005, doi: 10.1079/PHN2005801])
Device: r params$device
| Position: r params$position
| Side: r params$side
| Sampling rate: r params$sampling_rate
Hz | Filter: r params$filter
Epoch: r params$epoch
s | Nonwear time: Based on r params$axis_weartime
, interval of r params$frame_size
min with zero count for nonwear time detection, interval of r params$allowanceFrame_size
min with nonzero counts allowed during a nonwear period, interval of r params$streamFrame_size
min with zero count around detected activity to confirm nonwear time | MET equation: r params$equation_mets
| Axis used for PA intensity categorization: r params$axis_mvpa
| Cut-points: <r params$sed_cutpoint
counts/min for SED, $\geqslant$ r params$mpa_cutpoint
counts/min for MPA, $\geqslant$ r params$vpa_cutpoint
counts/min for VPA
Period of the day considered to count wear time: from r params$start_day_analysis
to r params$end_day_analysis
Minimum number of hours with wear time to validate a day: r params$minimum_wear_time_for_analysis
hours
Abbreviations: SED = sedentary, LPA = light physical activity, MPA = moderate physical activity, VPA = vigorous physical activity, MVPA = moderate-to-vigorous physical activity, PAL = physical activity level
plot_data_with_intensity( data = params$df_with_computed_metrics, metric = axis_mvpa_graph, valid_wear_time_start = params$start_day_analysis, valid_wear_time_end = params$end_day_analysis ) if (params$rendered_by_shiny) shiny::setProgress(0.25) # set progress to 25%
create_fig_res_by_day( df2, params$minimum_wear_time_for_analysis, params$start_day_analysis, params$end_day_analysis, language = "en", metrics = "volume" ) + theme(plot.margin = margin(1, 1, 1, 1, "cm"), axis.text.x = element_text(hjust = 1.1))
create_flextable_summary( results_summary_means = df1_means, results_summary_medians = df1_medians, language = "en", metrics = "volume", epoch_label = paste0(params$epoch, "s") ) if (params$rendered_by_shiny) shiny::setProgress(0.5) # set progress to 50%
# PAL g_pal <- create_fig_pal(score = df1_means[["pal"]], "en") + theme(plot.margin = margin(2, 1, 0.5, 1, "cm")) # Steps g_steps <- create_fig_steps(score = df1_means[["total_steps"]], "en") + theme(plot.margin = margin(0, 1, 0.5, 1, "cm")) # MVPA g_mvpa <- create_fig_mvpa(score = df1_means[["minutes_MVPA"]], "en") + theme(plot.margin = margin(0, 1, 0, 1, "cm")) # SED g_sed <- create_fig_sed(score = df1_means[["minutes_SED"]], "en") + theme(plot.margin = margin(0, 1, 0, 1, "cm")) # MVPA/SED ratio g_ratio <- create_fig_ratio_mvpa_sed(score = df1_means[["ratio_mvpa_sed"]], "en") + theme(plot.margin = margin(0, 1, 1, 1, "cm")) # Whole figure (g_pal + theme(legend.position = "top")) / g_steps / (g_mvpa | g_sed | g_ratio) + plot_layout(heights = c(0.8, 0.7, 1.5)) & theme(legend.justification = "center")
# Determining physical activity guidelines status guidelines_status <- get_guidelines_status(df1_means[["mets_hours_mvpa"]], language = "en") # Determining PAL status pal_status <- get_pal_status(df1_means[["pal"]], language = "en")
According to the Food and Agriculture Organization of the United Nations (FAO), the PAL of the patient could be characterized as r pal_status
. After converting moderate and vigorous physical activity minutes to MET-hours, the estimate of the daily mean of MVPA volume for the patient is r paste0(format(round(df1_means[["mets_hours_mvpa"]], 1), nsmall = 1))
MET-hr, which could correspond to falling r guidelines_status
(i.e., 7.5-15.0 MET-hr a week, or 1.07-2.14 MET-hr a day).
create_fig_res_by_day( df2, params$minimum_wear_time_for_analysis, params$start_day_analysis, params$end_day_analysis, language = "en", metrics = "step_acc" ) + theme(plot.margin = margin(1, 1, 1, 1, "cm"), axis.text.x = element_text(hjust = 1.1))
create_flextable_summary( df1_means, df1_medians, language = "en", metrics = "step_acc", epoch_label = paste0(params$epoch, "s") ) if (params$rendered_by_shiny) shiny::setProgress(0.75) # set progress to 75%
create_fig_res_by_day( df2, params$minimum_wear_time_for_analysis, params$start_day_analysis, params$end_day_analysis, language = "en", metrics = "int_distri", epoch_label = paste0(params$epoch, "s") ) + theme(plot.margin = margin(1, 1, 1, 1, "cm"), axis.text.x = element_text(hjust = 1.1))
create_flextable_summary( df1_means, df1_medians, language = "en", metrics = "int_distri", epoch_label = paste0(params$epoch, "s") )
cor_factor <- 60 / params$epoch create_fig_mx_summary( data = df1_means, labels = NULL, mpa_cutpoint = params$mpa_cutpoint / cor_factor, vpa_cutpoint = params$vpa_cutpoint / cor_factor ) + theme(legend.position = c(0.15, 0.08))
\newpage
if(length(params$p_breaks_sed) == 1) { cat("No results. Results can be obtained using 60-s epochs only.") } else { params$p_breaks_sed }
if(length(params$p_breaks_sed) == 1) { cat("No results. Results can be obtained using 60-s epochs only.") } else { p1 <- params$p_alpha_sed + guides(color = "none", fill = "none") p2 <- params$p_MBD_sed + guides(color = "none", fill = "none") p3 <- params$p_UBD_sed p4 <- params$p_gini_sed (p1 | p2 | p3 | p4) + plot_layout(guides = "collect") & theme(legend.position = 'bottom', axis.title = element_text(size = 15), legend.title = element_text(size = 17), legend.text = element_text(size = 15) ) }
\newpage
if(length(params$p_breaks_pa) == 1) { cat("No results. Results can be obtained using 60-s epochs only.") } else { params$p_breaks_pa } if (params$rendered_by_shiny) shiny::setProgress(1) # set progress to 100%
if(length(params$p_breaks_pa) == 1) { cat("No results. Results can be obtained using 60-s epochs only.") } else { p1 <- params$p_alpha_pa + guides(color = "none", fill = "none") p2 <- params$p_MBD_pa + guides(color = "none", fill = "none") p3 <- params$p_UBD_pa p4 <- params$p_gini_pa (p1 | p2 | p3 | p4) + plot_layout(guides = "collect") & theme(legend.position = 'bottom', axis.title = element_text(size = 15), legend.title = element_text(size = 17), legend.text = element_text(size = 15) ) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.