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

pre-release tm_t_crosstable document update #664

Merged
merged 7 commits into from
Feb 26, 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
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
m7pr marked this conversation as resolved.
Show resolved Hide resolved
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.