From 4a34ee80309fad46c865663de1e6aed4a47c6e81 Mon Sep 17 00:00:00 2001 From: kartikeya kirar Date: Mon, 26 Feb 2024 19:50:42 +0530 Subject: [PATCH] pre-release `tm_missing_data` document update (#668) part of https://github.com/insightsengineering/teal.modules.general/issues/624 --------- Co-authored-by: go_gonzo --- R/tm_missing_data.R | 21 ++++++++++++++------- man/tm_missing_data.Rd | 14 ++++++++------ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/R/tm_missing_data.R b/R/tm_missing_data.R index 4e856dffd..48f9f9941 100644 --- a/R/tm_missing_data.R +++ b/R/tm_missing_data.R @@ -1,13 +1,15 @@ -#' Missing data module +#' Missing data analysis module #' -#' Present analysis of missing observations and patients. -#' specifically designed for use with `data.frames`. +#' Module analyzes missing data in `data.frame`s to help users explore missing observations and +#' gain insights into the completeness of their data. +#' It is useful for clinical data analysis within the context of CDISC standards and +#' adaptable for general data analysis purposes. #' #' @inheritParams teal::module #' @inheritParams shared_params -#' @param parent_dataname (`character(1)`) If this `dataname` exists in then "the by subject"graph is displayed. -#' For `CDISC` data. In non `CDISC` data this can be ignored. Defaults to `"ADSL"`. -#' @param ggtheme optional, (`character`) `ggplot2` theme to be used by default. Defaults to `"classic"`. +#' @param parent_dataname (`character(1)`) Specifies the parent dataset name. Default is `ADSL` for CDISC data. +#' If provided and exists, enables additional analysis "by subject". For non-CDISC data, this parameter can be ignored. +#' @param ggtheme (`character`, optional) Specifies the default `ggplot2` theme for plots. Defaults to `classic`. #' #' @templateVar ggnames "Summary Obs", "Summary Patients", "Combinations Main", "Combinations Hist", "By Subject" #' @template ggplot2_args_multi @@ -120,6 +122,7 @@ tm_missing_data <- function(label = "Missing data", ) } +# UI function for the missing data module (all datasets) ui_page_missing_data <- function(id, pre_output = NULL, post_output = NULL) { ns <- NS(id) shiny::tagList( @@ -144,6 +147,7 @@ ui_page_missing_data <- function(id, pre_output = NULL, post_output = NULL) { ) } +# Server function for the missing data module (all datasets) srv_page_missing_data <- function(id, data, reporter, filter_panel_api, parent_dataname, plot_height, plot_width, ggplot2_args, ggtheme) { moduleServer(id, function(input, output, session) { @@ -230,6 +234,7 @@ srv_page_missing_data <- function(id, data, reporter, filter_panel_api, parent_d }) } +# UI function for the missing data module (single dataset) ui_missing_data <- function(id, by_subject_plot = FALSE) { ns <- NS(id) @@ -299,6 +304,7 @@ ui_missing_data <- function(id, by_subject_plot = FALSE) { ) } +# UI encoding for the missing data module (all datasets) encoding_missing_data <- function(id, summary_per_patient = FALSE, ggtheme, datanames) { ns <- NS(id) @@ -387,6 +393,7 @@ encoding_missing_data <- function(id, summary_per_patient = FALSE, ggtheme, data ) } +# Server function for the missing data (single dataset) srv_missing_data <- function(id, data, reporter, filter_panel_api, dataname, parent_dataname, plot_height, plot_width, ggplot2_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") @@ -491,7 +498,7 @@ srv_missing_data <- function(id, data, reporter, filter_panel_api, dataname, par } else { labels <- ifelse(cols == new_col_name | cols == "", cols, paste0(column_labels[cols], " [", cols, "]")) } - return(labels) + labels }, env = list( new_col_name = new_col_name, diff --git a/man/tm_missing_data.Rd b/man/tm_missing_data.Rd index 87b513723..6ca59c853 100644 --- a/man/tm_missing_data.Rd +++ b/man/tm_missing_data.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/tm_missing_data.R \name{tm_missing_data} \alias{tm_missing_data} -\title{Missing data module} +\title{Missing data analysis module} \usage{ tm_missing_data( label = "Missing data", @@ -27,10 +27,10 @@ For \code{modules()} defaults to \code{"root"}. See \code{Details}.} \item{plot_width}{optional, (\code{numeric}) Specifies the plot width as a three-element vector of \code{value}, \code{min}, and \code{max} for a slider encoding the plot width.} -\item{parent_dataname}{(\code{character(1)}) If this \code{dataname} exists in then "the by subject"graph is displayed. -For \code{CDISC} data. In non \code{CDISC} data this can be ignored. Defaults to \code{"ADSL"}.} +\item{parent_dataname}{(\code{character(1)}) Specifies the parent dataset name. Default is \code{ADSL} for CDISC data. +If provided and exists, enables additional analysis "by subject". For non-CDISC data, this parameter can be ignored.} -\item{ggtheme}{optional, (\code{character}) \code{ggplot2} theme to be used by default. Defaults to \code{"classic"}.} +\item{ggtheme}{(\code{character}, optional) Specifies the default \code{ggplot2} theme for plots. Defaults to \code{classic}.} \item{ggplot2_args}{optional, (\code{ggplot2_args}) object created by \code{\link[teal.widgets:ggplot2_args]{teal.widgets::ggplot2_args()}} with settings for all the plots or named list of \code{ggplot2_args} objects for plot-specific settings. @@ -48,8 +48,10 @@ with text placed before the output to put the output into context. For example a adding context or further instructions. Elements like \code{shiny::helpText()} are useful.} } \description{ -Present analysis of missing observations and patients. -specifically designed for use with \code{data.frames}. +Module analyzes missing data in \code{data.frame}s to help users explore missing observations and +gain insights into the completeness of their data. +It is useful for clinical data analysis within the context of CDISC standards and +adaptable for general data analysis purposes. } \examples{ library(teal.widgets)