TailorExercisePlan {T2DFitTailor}R Documentation

Visualize Tailored Exercise Plan for T2D Patients

Description

This function visualizes the exercise plan recommendations for Type 2 Diabetes (T2D) patients by generating radar charts.

Arguments

demo_result

A list containing two data frames (⁠$RecommendedExercisePlan⁠ and ⁠$AllExercisePlan⁠) as returned by the TailorExercisePlan function.

sample_selection

Specifies which patient samples to visualize, accepting three types of inputs:

  • "all": Visualizes all samples.

  • Given names (character vector): Names of specific patients for visualization.

  • Numeric value: A numeric index indicating the number of samples to visualize.

sort_by

Determines the sorting orientation for the visualization, affecting which samples are prioritized:

  • "head": Prioritizes samples towards the beginning of the selection.

  • "tail": Prioritizes samples towards the end of the selection.

exercise_type

Specifies the type(s) of exercises to include in the visualization. Accepts multiple input types:

  • "all": Includes all types of exercises.

  • "best": Selects the exercise(s) with the highest predicted reduction in HbA1c.

  • Given types (character vector): Specific exercises, including "Taiji", "Qigong", "Stretching", "Rugby", "Cycling", and "Walking".

nrow

The number of rows in the visualization grid, which can be:

  • "auto": Automatically calculates the number of rows based on the number of samples and other parameters.

  • Numeric value: Specifies the exact number of rows for the layout.

ncol

The number of columns in the visualization grid, which can be:

  • "auto": Automatically calculates the number of columns based on the number of samples, the specified number of rows, and other parameters.

  • Numeric value: Specifies the exact number of columns for the layout.

show_legend

A logical value indicating whether to display a legend in the plots. TRUE or FALSE.

Value

The function does not return a data structure, but rather invisibly produces radar charts. These charts visualize the expected HbA1c decrease value and other relevant details for each recommended exercise plan for T2D patients.

Examples


#Create a demo dataframe
set.seed(5)
df <- data.frame(
  Age = sample(39:77, 8, replace = TRUE),
  Sex = sample(0:1, 8, replace = TRUE),
  BMI = sample(18:31, 8, replace = TRUE),
  WHtR = sample(0.4:0.6, 8, replace = TRUE),
  PCS = sample(27:54, 8, replace = TRUE),
  Duration_T2D = sample(1:26, 8, replace = TRUE),
  Total_cholesterol = sample(7.4:14.1, 8, replace = TRUE),
  HDL = sample(1:1.7, 8, replace = TRUE),
  LDL = sample(2.2:4.7, 8, replace = TRUE),
  VO2_Max = sample(13:45, 8, replace = TRUE),
  Lung_capacity = sample(1900:4600, 8, replace = TRUE),
  Back_Scratch_Test = sample(-30:8, 8, replace = TRUE))

names(df) <- c('Age', 'Sex', 'BMI', 'WHtR', 'PCS', 'Duration_T2D (year)',
              'Total cholesterol (mmol/L)', 'HDL (mmol/L)', 'LDL (mmol/L)',
              'VO2_Max (ml/kg/min)', 'Lung_capacity (ml)', 'Back_Scratch_Test (cm)')
rownames(df) <- c('Sample1', 'Sample2', 'Sample3', 'Sample4',
                  'Sample5', 'Sample6', 'Sample7', 'Sample8')

# Run the TailorExercisePlan function
demo_result <- TailorExercisePlan(df)

# Visualize the outcome from 'TailorExercisePlan' function
VisualizeTailoredExercisePlan(demo_result,sample_selection="all",sort_by="head",
                              exercise_type="best",nrow="auto",ncol="auto",show_legend=TRUE)

VisualizeTailoredExercisePlan(demo_result,sample_selection="Sample1",sort_by="head",
                              exercise_type="all",nrow="auto",ncol="auto",show_legend=TRUE)


[Package T2DFitTailor version 3.0.0 Index]