|
1 | | -#' Response Plots |
2 | | -#' @md |
| 1 | +#' Response plot module |
| 2 | +#' |
| 3 | +#' Generates a response plot for a given `response` and `x` variables. |
| 4 | +#' This module allows users customize and add annotations to the plot depending |
| 5 | +#' on the module's arguments. |
| 6 | +#' It supports showing the counts grouped by other variable facets (by row / column), |
| 7 | +#' swapping the coordinates, show count annotations and displaying the response plot |
| 8 | +#' as frequency or density. |
3 | 9 | #' |
4 | 10 | #' @inheritParams teal::module |
5 | 11 | #' @inheritParams shared_params |
6 | 12 | #' @param response (`data_extract_spec` or `list` of multiple `data_extract_spec`) |
7 | | -#' Which variable to use as the response. You can define one fixed column by using the |
8 | | -#' setting `fixed = TRUE` inside the `select_spec`. |
9 | | -#' `data_extract_spec` must not allow multiple selection in this case. |
| 13 | +#' Which variable to use as the response. |
| 14 | +#' You can define one fixed column by setting `fixed = TRUE` inside the `select_spec`. |
| 15 | +#' |
| 16 | +#' The `data_extract_spec` must not allow multiple selection in this case. |
10 | 17 | #' @param x (`data_extract_spec` or `list` of multiple `data_extract_spec`) |
11 | | -#' Which variable to use on the X-axis of the response plot. Allow the user to select multiple |
12 | | -#' columns from the `data` allowed in teal. |
13 | | -#' `data_extract_spec` must not allow multiple selection in this case. |
14 | | -#' @param row_facet optional, (`data_extract_spec` or `list` of multiple `data_extract_spec`) |
15 | | -#' Which data columns to use for faceting rows. |
16 | | -#' @param col_facet optional, (`data_extract_spec` or `list` of multiple `data_extract_spec`) |
17 | | -#' Which data to use for faceting columns. |
18 | | -#' @param coord_flip optional, (`logical`) Whether to flip coordinates between `x` and `response`. |
19 | | -#' @param count_labels optional, (`logical`) Whether to show count labels. |
20 | | -#' Defaults to `TRUE`. |
21 | | -#' @param freq optional, (`logical`) Whether to display frequency (`TRUE`) or density (`FALSE`). |
22 | | -#' Defaults to density (`FALSE`). |
| 18 | +#' Specifies which variable to use on the X-axis of the response plot. |
| 19 | +#' Allow the user to select multiple columns from the `data` allowed in teal. |
| 20 | +#' |
| 21 | +#' The `data_extract_spec` must not allow multiple selection in this case. |
| 22 | +#' @param row_facet (`data_extract_spec` or `list` of multiple `data_extract_spec`) |
| 23 | +#' optional specification of the data variable(s) to use for faceting rows. |
| 24 | +#' @param col_facet (`data_extract_spec` or `list` of multiple `data_extract_spec`) |
| 25 | +#' optional specification of the data variable(s) to use for faceting columns. |
| 26 | +#' @param coord_flip (`logical(1)`) |
| 27 | +#' Indicates whether to flip coordinates between `x` and `response`. |
| 28 | +#' The default value is `FALSE` and it will show the `x` variable on the x-axis |
| 29 | +#' and the `response` variable on the y-axis. |
| 30 | +#' @param count_labels (`logical(1)`) |
| 31 | +#' Indicates whether to show count labels. |
| 32 | +#' Defaults to `TRUE`. |
| 33 | +#' @param freq (`logical(1)`) |
| 34 | +#' Indicates whether to display frequency (`TRUE`) or density (`FALSE`). |
| 35 | +#' Defaults to density (`FALSE`). |
| 36 | +#' |
| 37 | +#' @inherit shared_params return |
23 | 38 | #' |
24 | 39 | #' @note For more examples, please see the vignette "Using response plot" via |
25 | | -#' \code{vignette("using-response-plot", package = "teal.modules.general")}. |
| 40 | +#' `vignette("using-response-plot", package = "teal.modules.general")`. |
26 | 41 | #' |
27 | 42 | #' @examples |
28 | 43 | #' # general data example |
@@ -195,6 +210,7 @@ tm_g_response <- function(label = "Response Plot", |
195 | 210 | ) |
196 | 211 | } |
197 | 212 |
|
| 213 | +# UI function for the response module |
198 | 214 | ui_g_response <- function(id, ...) { |
199 | 215 | ns <- NS(id) |
200 | 216 | args <- list(...) |
@@ -270,6 +286,7 @@ ui_g_response <- function(id, ...) { |
270 | 286 | ) |
271 | 287 | } |
272 | 288 |
|
| 289 | +# Server function for the response module |
273 | 290 | srv_g_response <- function(id, |
274 | 291 | data, |
275 | 292 | reporter, |
|
0 commit comments