diff --git a/R/tm_t_crosstable.R b/R/tm_t_crosstable.R index cbcdb6d6d..8fdc090e6 100644 --- a/R/tm_t_crosstable.R +++ b/R/tm_t_crosstable.R @@ -1,22 +1,29 @@ -#' Create a simple cross-table -#' @md +#' Cross-table module +#' +#' Generates a simple cross-table of two variables from a dataset with custom +#' options for showing percentages and sub-totals. #' #' @inheritParams teal::module #' @inheritParams shared_params #' @param x (`data_extract_spec` or `list` of multiple `data_extract_spec`) -#' Object with all available choices with pre-selected option for variable X - row values. In case -#' of `data_extract_spec` use `select_spec(..., ordered = TRUE)` if table elements should be -#' rendered according to selection order. +#' Object with all available choices with pre-selected option for variable X - row values. +#' In case of `data_extract_spec` use `select_spec(..., ordered = TRUE)` if table elements should be +#' rendered according to selection order. #' @param y (`data_extract_spec` or `list` of multiple `data_extract_spec`) -#' Object with all available choices with pre-selected option for variable Y - column values -#' \code{data_extract_spec} must not allow multiple selection in this case. +#' Object with all available choices with pre-selected option for variable Y - column values. #' -#' @param show_percentage optional, (`logical`) Whether to show percentages -#' (relevant only when `x` is a `factor`). Defaults to `TRUE`. -#' @param show_total optional, (`logical`) Whether to show total column. Defaults to `TRUE`. +#' `data_extract_spec` must not allow multiple selection in this case. +#' @param show_percentage (`logical(1)`) +#' Indicates whether to show percentages (relevant only when `x` is a `factor`). +#' Defaults to `TRUE`. +#' @param show_total (`logical(1)`) +#' Indicates whether to show total column. +#' Defaults to `TRUE`. #' #' @note For more examples, please see the vignette "Using cross table" via -#' `vignette("using-cross-table", package = "teal.modules.general")`. +#' `vignette("using-cross-table", package = "teal.modules.general")`. +#' +#' @inherit shared_params return #' #' @examples #' # general data example @@ -167,6 +174,7 @@ tm_t_crosstable <- function(label = "Cross Table", ) } +# UI function for the cross-table module ui_t_crosstable <- function(id, x, y, show_percentage, show_total, pre_output, post_output, ...) { ns <- NS(id) is_single_dataset <- teal.transform::is_single_dataset(x, y) @@ -216,6 +224,7 @@ ui_t_crosstable <- function(id, x, y, show_percentage, show_total, pre_output, p ) } +# Server function for the cross-table module srv_t_crosstable <- function(id, data, reporter, filter_panel_api, label, x, y, basic_table_args) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") diff --git a/man/tm_t_crosstable.Rd b/man/tm_t_crosstable.Rd index 155f6bc90..6965390ea 100644 --- a/man/tm_t_crosstable.Rd +++ b/man/tm_t_crosstable.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/tm_t_crosstable.R \name{tm_t_crosstable} \alias{tm_t_crosstable} -\title{Create a simple cross-table} +\title{Cross-table module} \usage{ tm_t_crosstable( label = "Cross Table", @@ -20,18 +20,22 @@ tm_t_crosstable( For \code{modules()} defaults to \code{"root"}. See \code{Details}.} \item{x}{(\code{data_extract_spec} or \code{list} of multiple \code{data_extract_spec}) -Object with all available choices with pre-selected option for variable X - row values. In case -of \code{data_extract_spec} use \code{select_spec(..., ordered = TRUE)} if table elements should be +Object with all available choices with pre-selected option for variable X - row values. +In case of \code{data_extract_spec} use \code{select_spec(..., ordered = TRUE)} if table elements should be rendered according to selection order.} \item{y}{(\code{data_extract_spec} or \code{list} of multiple \code{data_extract_spec}) -Object with all available choices with pre-selected option for variable Y - column values +Object with all available choices with pre-selected option for variable Y - column values. + \code{data_extract_spec} must not allow multiple selection in this case.} -\item{show_percentage}{optional, (\code{logical}) Whether to show percentages -(relevant only when \code{x} is a \code{factor}). Defaults to \code{TRUE}.} +\item{show_percentage}{(\code{logical(1)}) +Indicates whether to show percentages (relevant only when \code{x} is a \code{factor}). +Defaults to \code{TRUE}.} -\item{show_total}{optional, (\code{logical}) Whether to show total column. Defaults to \code{TRUE}.} +\item{show_total}{(\code{logical(1)}) +Indicates whether to show total column. +Defaults to \code{TRUE}.} \item{pre_output}{(\code{shiny.tag}, optional)\cr with text placed before the output to put the output into context. For example a title.} @@ -45,8 +49,12 @@ The argument is merged with options variable \code{teal.basic_table_args} and de For more details see the vignette: \code{vignette("custom-basic-table-arguments", package = "teal.widgets")}} } +\value{ +Object of class \code{teal_module} to be used in \code{teal} applications. +} \description{ -Create a simple cross-table +Generates a simple cross-table of two variables from a dataset with custom +options for showing percentages and sub-totals. } \note{ For more examples, please see the vignette "Using cross table" via