Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add total episodes to profile and documentation #144

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions R/epicalc_profile.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,23 @@ epicalc_profile <- function(data,lv1_hypo=70,lv2_hypo=54,lv1_hyper=180,lv2_hyper
tableStat[6, 7] = paste0(as.character(format(round(ep_summary$avg_ep_gl[6], 2), nsmall = 2)), " mg/dl")
tableStat[6, 8] = paste0(as.character(format(round(ep_summary$avg_ep_gl[7], 2), nsmall = 2)), " mg/dl")

tableStat[7, 1] = "Total episodes"
tableStat[7, 2] = paste0(as.character(format(round(ep_summary$total_episodes[1], 2), nsmall = 2)))
tableStat[7, 3] = paste0(as.character(format(round(ep_summary$total_episodes[2], 2), nsmall = 2)))
tableStat[7, 4] = paste0(as.character(format(round(ep_summary$total_episodes[3], 2), nsmall = 2)))
tableStat[7, 5] = paste0(as.character(format(round(ep_summary$total_episodes[4], 2), nsmall = 2)))
tableStat[7, 6] = paste0(as.character(format(round(ep_summary$total_episodes[5], 2), nsmall = 2)))
tableStat[7, 7] = paste0(as.character(format(round(ep_summary$total_episodes[6], 2), nsmall = 2)))
tableStat[7, 8] = paste0(as.character(format(round(ep_summary$total_episodes[7], 2), nsmall = 2)))

#Styling the table
mytheme <- gridExtra::ttheme_minimal(base_size = 10, padding = unit(c(4,2),"mm"))
t1 <- gridExtra::tableGrob(tableStat, rows = NULL, cols = NULL, theme = mytheme )

#Adding border(t1)
t1 <- gtable::gtable_add_grob(t1,
grobs = grid::rectGrob(gp = grid::gpar(fill = NA, lwd = 5)),
t = 1, b = 6, l = 1, r = 8)
t = 1, b = 7, l = 1, r = 8)
#Adding dotted separator(t1)
separators <- replicate(ncol(t1) - 2,
grid::segmentsGrob(x1 = unit(0, "npc"), gp=grid::gpar(lty=2)),
Expand All @@ -120,7 +129,7 @@ epicalc_profile <- function(data,lv1_hypo=70,lv2_hypo=54,lv1_hyper=180,lv2_hyper
padding <- unit(0.5,"line")

#Adding title and footnote(t1)
title <- grid::textGrob("Episode Metrics",gp=grid::gpar(fontsize=18), x=0, hjust=0)
title <- grid::textGrob(paste0("Episode Metrics - ", data$id[1]),gp=grid::gpar(fontsize=18), x=0, hjust=0)
footnote <- grid::textGrob(paste0("An episode is >= ", dur_length, " continuous minutes"), x=1, hjust=1,
gp=grid::gpar( fontface="italic", fontsize = 8))

Expand Down
1 change: 1 addition & 0 deletions R/episode_calculation.R
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ episode_single = function(data, lv1_hypo, lv2_hypo, lv1_hyper, lv2_hyper,
#' (total # episodes)/(recording time in days (24hrs))}
#' \item{avg_ep_duration}{Average duration of episodes in minutes}
#' \item{avg_ep_gl}{Average glucose in the episode in mg/dL}
#' \item{total_episodes}{Total number of episodes in the subject's glucose trace}
#'
#' If return_data is TRUE, returns a list where the first entry is the episode summary dataframe
#' (see above) and the second entry is the input data with episode labels added. Note
Expand Down
1 change: 1 addition & 0 deletions man/episode_calculation.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.