knitr::opts_chunk$set(echo = TRUE, message=FALSE, warning=FALSE, echo = FALSE)
library(magrittr)
library(ggplot2)
library(patchwork)

options("scipen"=100, "digits"=4)

Information

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")

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

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

Summary

diff_raw <-
  ggplot(data = data.frame(x = 0.1, y = 0.6, label = params$dppac_diff_raw), aes(x, y, label = paste0(label, " / 20"))) +
  geom_text(size = 17, color = "white", fontface = "bold", hjust = 0) +
  coord_cartesian(xlim = c(0, 1), ylim = c(0, 1), expand = FALSE) +
  annotate("text", x = 0.1, y = 0.2, label = "Difficulty score (raw)", color = "white", fontface = "bold", hjust = 0, size = 6) +
  theme_void() +
  theme(
    panel.background = element_rect(fill = "#00CEF1", color = "white", size = 10)
  )

amount_raw <-
  ggplot(data = data.frame(x = 0.1, y = 0.6, label = params$dppac_amount_raw), aes(x, y, label = paste0(label, " / 17"))) +
  geom_text(size = 17, color = "white", fontface = "bold", hjust = 0) +
  coord_cartesian(xlim = c(0, 1), ylim = c(0, 1), expand = FALSE) +
  annotate("text", x = 0.1, y = 0.2, label = "Amount score (raw)", color = "white", fontface = "bold", hjust = 0, size = 6) +
  theme_void() +
  theme(
    panel.background = element_rect(fill = "#39cccc", color = "white", size = 10)
  )

total_raw <-
  ggplot(data = data.frame(x = 0.1, y = 0.6, label = params$dppac_total_raw), aes(x, y, label = paste0(label, " / 37"))) +
  geom_text(size = 17, color = "white", fontface = "bold", hjust = 0) +
  coord_cartesian(xlim = c(0, 1), ylim = c(0, 1), expand = FALSE) +
  annotate("text", x = 0.1, y = 0.2, label = "Total score (raw)", color = "white", fontface = "bold", hjust = 0, size = 6) +
  theme_void() +
  theme(
    panel.background = element_rect(fill = "#605ca8", color = "white", size = 10)
  )

if (params$rendered_by_shiny)
  shiny::setProgress(0.5)  # set progress to 50%


diff_rasch <-
  ggplot(data = data.frame(x = 0.1, y = 0.6, label = params$dppac_diff_rasch), aes(x, y, label = paste0(label, " / 100"))) +
  geom_text(size = 17, color = "white", fontface = "bold", hjust = 0) +
  coord_cartesian(xlim = c(0, 1), ylim = c(0, 1), expand = FALSE) +
  annotate("text", x = 0.1, y = 0.2, label = "Difficulty score (Rasch)", color = "white", fontface = "bold", hjust = 0, size = 6) +
  theme_void() +
  theme(
    panel.background = element_rect(fill = "#00CEF1", color = "white", size = 10)
  )

amount_rasch <-
  ggplot(data = data.frame(x = 0.1, y = 0.6, label = params$dppac_amount_rasch), aes(x, y, label = paste0(label, " / 100"))) +
  geom_text(size = 17, color = "white", fontface = "bold", hjust = 0) +
  coord_cartesian(xlim = c(0, 1), ylim = c(0, 1), expand = FALSE) +
  annotate("text", x = 0.1, y = 0.2, label = "Amount score (Rasch)", color = "white", fontface = "bold", hjust = 0, size = 6) +
  theme_void() +
  theme(
    panel.background = element_rect(fill = "#39cccc", color = "white", size = 10)
  )

total_rasch <-
  ggplot(data = data.frame(x = 0.1, y = 0.6, label = params$dppac_total_rasch), aes(x, y, label = paste0(label, " / 100"))) +
  geom_text(size = 17, color = "white", fontface = "bold", hjust = 0) +
  coord_cartesian(xlim = c(0, 1), ylim = c(0, 1), expand = FALSE) +
  annotate("text", x = 0.1, y = 0.2, label = "Total score (Rasch)", color = "white", fontface = "bold", hjust = 0, size = 6) +
  theme_void() +
  theme(
    panel.background = element_rect(fill = "#605ca8", color = "white", size = 10)
  )

(diff_raw | amount_raw | total_raw) / (diff_rasch | amount_rasch | total_rasch)

if (params$rendered_by_shiny)
  shiny::setProgress(1)  # set progress to 100%

\pagebreak

Details

flextable::set_flextable_defaults(fonts_ignore = TRUE)
flextable::flextable(params$dppac_table) %>%
   flextable::theme_zebra() %>%
   flextable::align(align = "left", part = "all" ) %>%
   flextable::width(j = "Day", width = 0.6) %>%
   flextable::width(j = "Item", width = 3.2) %>%
   flextable::width(j = c("Difficulty score", "Amount score"), width = 1) %>%
   flextable::align(j = "Difficulty score", align = "center", part = "body") %>%
   flextable::align(j = "Amount score", align = "center", part = "body") %>%
   flextable::align(j = "Difficulty score", align = "center", part = "header") %>%
   flextable::align(j = "Amount score", align = "center", part = "header")


pydemull/activAnalyzer documentation built on June 1, 2025, 1:09 p.m.