Skip to content

Commit b68f452

Browse files
update documentation tm_missing_data
1 parent c57bc17 commit b68f452

File tree

2 files changed

+39
-27
lines changed

2 files changed

+39
-27
lines changed

R/tm_missing_data.R

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
#' Missing data module
1+
#' Missing data analysis module
22
#'
3-
#' Present analysis of missing observations and patients.
4-
#' specifically designed for use with `data.frames`.
3+
#' Module analyzes missing data in `data.frame`s to help users explore missing observations and
4+
#' gain insights into the completeness of their data.
5+
#' It is useful for clinical data analysis within the context of CDISC standards and
6+
#' adaptable for general data analysis purposes.
57
#'
68
#' @inheritParams teal::module
79
#' @inheritParams shared_params
8-
#' @param parent_dataname (`character(1)`) If this `dataname` exists in then "the by subject"graph is displayed.
9-
#' For `CDISC` data. In non `CDISC` data this can be ignored. Defaults to `"ADSL"`.
10-
#' @param ggtheme optional, (`character`) `ggplot2` theme to be used by default. Defaults to `"classic"`.
10+
#' @param parent_dataname (`character(1)`) Specifies the parent dataset name. Default is `ADSL` for CDISC data.
11+
#' If provided and exists, enables additional analysis "by subject". For non-CDISC data, this parameter can be ignored.
12+
#' @param ggtheme (`character`, optional) Specifies the default `ggplot2` theme for plots. Defaults to `classic`.
1113
#'
1214
#' @templateVar ggnames "Summary Obs", "Summary Patients", "Combinations Main", "Combinations Hist", "By Subject"
1315
#' @template ggplot2_args_multi
1416
#'
15-
#' @export
16-
#'
1717
#' @examples
18-
#'
18+
#' library(teal.widgets)
1919
#' data <- teal_data()
2020
#' data <- within(data, {
2121
#' library(nestcolor)
@@ -26,22 +26,25 @@
2626
#' datanames(data) <- datanames
2727
#' join_keys(data) <- default_cdisc_join_keys[datanames]
2828
#'
29-
#' app <- teal::init(
29+
#' app <- init(
3030
#' data = data,
31-
#' modules = teal::modules(
32-
#' teal.modules.general::tm_missing_data(
31+
#' modules = modules(
32+
#' tm_missing_data(
3333
#' ggplot2_args = list(
34-
#' "Combinations Hist" = teal.widgets::ggplot2_args(
34+
#' "Combinations Hist" = ggplot2_args(
3535
#' labs = list(subtitle = "Plot produced by Missing Data Module", caption = NULL)
3636
#' ),
37-
#' "Combinations Main" = teal.widgets::ggplot2_args(labs = list(title = NULL))
37+
#' "Combinations Main" = ggplot2_args(labs = list(title = NULL))
3838
#' )
3939
#' )
4040
#' )
4141
#' )
4242
#' if (interactive()) {
4343
#' shinyApp(app$ui, app$server)
4444
#' }
45+
#'
46+
#' @export
47+
#'
4548
tm_missing_data <- function(label = "Missing data",
4649
plot_height = c(600, 400, 5000),
4750
plot_width = NULL,
@@ -89,6 +92,7 @@ tm_missing_data <- function(label = "Missing data",
8992
)
9093
}
9194

95+
# UI function for the missing data module.
9296
ui_page_missing_data <- function(id, pre_output = NULL, post_output = NULL) {
9397
ns <- NS(id)
9498
shiny::tagList(
@@ -113,6 +117,7 @@ ui_page_missing_data <- function(id, pre_output = NULL, post_output = NULL) {
113117
)
114118
}
115119

120+
# Server function for the missing data module.
116121
srv_page_missing_data <- function(id, data, reporter, filter_panel_api, parent_dataname,
117122
plot_height, plot_width, ggplot2_args, ggtheme) {
118123
moduleServer(id, function(input, output, session) {
@@ -199,6 +204,7 @@ srv_page_missing_data <- function(id, data, reporter, filter_panel_api, parent_d
199204
})
200205
}
201206

207+
# UI function for the missing data module.
202208
ui_missing_data <- function(id, by_subject_plot = FALSE) {
203209
ns <- NS(id)
204210

@@ -268,6 +274,8 @@ ui_missing_data <- function(id, by_subject_plot = FALSE) {
268274
)
269275
}
270276

277+
#' @noRd
278+
#' @keywords internal
271279
encoding_missing_data <- function(id, summary_per_patient = FALSE, ggtheme, datanames) {
272280
ns <- NS(id)
273281

@@ -356,6 +364,7 @@ encoding_missing_data <- function(id, summary_per_patient = FALSE, ggtheme, data
356364
)
357365
}
358366

367+
# Server function for the missing data module.
359368
srv_missing_data <- function(id, data, reporter, filter_panel_api, dataname, parent_dataname,
360369
plot_height, plot_width, ggplot2_args) {
361370
with_reporter <- !missing(reporter) && inherits(reporter, "Reporter")
@@ -460,7 +469,7 @@ srv_missing_data <- function(id, data, reporter, filter_panel_api, dataname, par
460469
} else {
461470
labels <- ifelse(cols == new_col_name | cols == "", cols, paste0(column_labels[cols], " [", cols, "]"))
462471
}
463-
return(labels)
472+
labels
464473
},
465474
env = list(
466475
new_col_name = new_col_name,

man/tm_missing_data.Rd

Lines changed: 15 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)