Skip to content

Commit

Permalink
pre-release tm_t_crosstable document update (#664)
Browse files Browse the repository at this point in the history
part of #624

~blocked by #651~
  • Loading branch information
averissimo authored Feb 26, 2024
1 parent 51ef394 commit 0cb0b56
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 19 deletions.
31 changes: 20 additions & 11 deletions R/tm_t_crosstable.R
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down
24 changes: 16 additions & 8 deletions man/tm_t_crosstable.Rd

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

0 comments on commit 0cb0b56

Please sign in to comment.